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/AIRuntimeActionMove.cs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/AI/AIRuntimeActionMove.cs (limited to 'Client/Assets/Scripts/XMainClient/AI/AIRuntimeActionMove.cs') diff --git a/Client/Assets/Scripts/XMainClient/AI/AIRuntimeActionMove.cs b/Client/Assets/Scripts/XMainClient/AI/AIRuntimeActionMove.cs new file mode 100644 index 00000000..5912ec67 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/AI/AIRuntimeActionMove.cs @@ -0,0 +1,42 @@ +using System; +using System.Xml; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class AIRuntimeActionMove : AIRunTimeNodeAction + { + private string _move_dir; + + private string _move_dest; + + private string _move_speed; + + public AIRuntimeActionMove(XmlElement node) : base(node) + { + this._move_dir = node.GetAttribute("Shared_MoveDirName"); + this._move_dest = node.GetAttribute("Shared_MoveDestName"); + this._move_speed = node.GetAttribute("Shared_MoveSpeedName"); + } + + public override bool Update(XEntity entity) + { + Vector3 vector = entity.AI.AIData.GetVector3ByName(this._move_dir, Vector3.zero); + Vector3 vector2 = entity.AI.AIData.GetVector3ByName(this._move_dest, Vector3.zero); + bool flag = vector == Vector3.zero; + if (flag) + { + vector = (vector2 - entity.EngineObject.Position).normalized; + vector.Set(vector.x, 0f, vector.z); + } + bool flag2 = vector2 == Vector3.zero; + if (flag2) + { + vector2 = entity.EngineObject.Position + vector.normalized * 50f; + } + float floatByName = entity.AI.AIData.GetFloatByName(this._move_speed, 0f); + return XSingleton.singleton.ActionMove(entity, vector, vector2, floatByName); + } + } +} -- cgit v1.1-26-g67d0