summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/AI/AIRuntimeNavToTarget.cs
blob: 96470513f19be8f8669dd71c65ee323a451d23a7 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Xml;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient
{
	internal class AIRuntimeNavToTarget : AIRunTimeNodeAction
	{
		private string _target_name;

		private string _nav_target_name;

		private Vector3 _nav_pos;

		private string _nav_pos_name;

		public AIRuntimeNavToTarget(XmlElement node) : base(node)
		{
			this._target_name = node.GetAttribute("Shared_TargetName");
			this._nav_target_name = node.GetAttribute("Shared_NavTargetName");
			this._nav_pos_name = node.GetAttribute("Shared_NavPosName");
			string attribute = node.GetAttribute("Shared_NavPosmValue");
			float num = float.Parse(attribute.Split(new char[]
			{
				':'
			})[0]);
			float num2 = float.Parse(attribute.Split(new char[]
			{
				':'
			})[1]);
			float num3 = float.Parse(attribute.Split(new char[]
			{
				':'
			})[2]);
			this._nav_pos = new Vector3(num, num2, num3);
		}

		public override bool Update(XEntity entity)
		{
			XGameObject xgameObjectByName = entity.AI.AIData.GetXGameObjectByName(this._target_name);
			bool flag = xgameObjectByName == null;
			bool result;
			if (flag)
			{
				Transform transformByName = entity.AI.AIData.GetTransformByName(this._nav_target_name);
				bool flag2 = transformByName == null;
				if (flag2)
				{
					bool flag3 = string.IsNullOrEmpty(this._nav_pos_name);
					if (flag3)
					{
						bool flag4 = this._nav_pos == Vector3.zero;
						result = (!flag4 && XSingleton<XAIGeneralMgr>.singleton.ActionNav(entity.ID, this._nav_pos));
					}
					else
					{
						Vector3 vector3ByName = entity.AI.AIData.GetVector3ByName(this._nav_pos_name, Vector3.zero);
						result = XSingleton<XAIGeneralMgr>.singleton.ActionNav(entity.ID, vector3ByName);
					}
				}
				else
				{
					result = XSingleton<XAIGeneralMgr>.singleton.NavToTarget(entity.ID, transformByName.gameObject);
				}
			}
			else
			{
				result = XSingleton<XAIMove>.singleton.NavToTarget(entity, xgameObjectByName.Position, entity.AI.MoveSpeed);
			}
			return result;
		}
	}
}