From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/AI/AIRuntimeNavToTarget.cs | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/AI/AIRuntimeNavToTarget.cs (limited to 'Client/Assets/Scripts/XMainClient/AI/AIRuntimeNavToTarget.cs') diff --git a/Client/Assets/Scripts/XMainClient/AI/AIRuntimeNavToTarget.cs b/Client/Assets/Scripts/XMainClient/AI/AIRuntimeNavToTarget.cs new file mode 100644 index 00000000..96470513 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/AI/AIRuntimeNavToTarget.cs @@ -0,0 +1,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.singleton.ActionNav(entity.ID, this._nav_pos)); + } + else + { + Vector3 vector3ByName = entity.AI.AIData.GetVector3ByName(this._nav_pos_name, Vector3.zero); + result = XSingleton.singleton.ActionNav(entity.ID, vector3ByName); + } + } + else + { + result = XSingleton.singleton.NavToTarget(entity.ID, transformByName.gameObject); + } + } + else + { + result = XSingleton.singleton.NavToTarget(entity, xgameObjectByName.Position, entity.AI.MoveSpeed); + } + return result; + } + } +} -- cgit v1.1-26-g67d0