summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/AI/AIRunTimeRandomSelectorNode.cs
blob: d0dd80d5d8eced42555ad8d2a34b45fce7ae42ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Xml;

namespace XMainClient
{
	internal class AIRunTimeRandomSelectorNode : AIRunTimeLogicNode
	{
		protected AIRunTimeRandomIndex _random_index = null;

		public AIRunTimeRandomSelectorNode(XmlElement node) : base(node)
		{
			this._random_index = new AIRunTimeRandomIndex();
		}

		public override void AddChild(AIRunTimeNodeBase child)
		{
			base.AddChild(child);
			this._random_index.AppendIndex();
		}

		public override bool Update(XEntity entity)
		{
			this._random_index.Rand();
			for (int i = 0; i < this._list_node.Count; i++)
			{
				bool flag = this._list_node[this._random_index[i]].Update(entity);
				if (flag)
				{
					return true;
				}
			}
			return false;
		}
	}
}