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/AIRunTimeRandomFloat.cs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/AI/AIRunTimeRandomFloat.cs (limited to 'Client/Assets/Scripts/XMainClient/AI/AIRunTimeRandomFloat.cs') diff --git a/Client/Assets/Scripts/XMainClient/AI/AIRunTimeRandomFloat.cs b/Client/Assets/Scripts/XMainClient/AI/AIRunTimeRandomFloat.cs new file mode 100644 index 00000000..e65d035e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/AI/AIRunTimeRandomFloat.cs @@ -0,0 +1,37 @@ +using System; +using System.Xml; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class AIRunTimeRandomFloat : AIRunTimeNodeAction + { + private float _min_value; + + private string _min_name; + + private float _max_value; + + private string _max_name; + + private string _store_result_name; + + public AIRunTimeRandomFloat(XmlElement node) : base(node) + { + this._min_value = float.Parse(node.GetAttribute("minValue")); + this._min_name = node.GetAttribute("Shared_MinName"); + this._max_value = float.Parse(node.GetAttribute("maxValue")); + this._max_name = node.GetAttribute("Shared_MaxName"); + this._store_result_name = node.GetAttribute("Shared_StoredResultName"); + } + + public override bool Update(XEntity entity) + { + float floatByName = entity.AI.AIData.GetFloatByName(this._min_name, this._min_value); + float floatByName2 = entity.AI.AIData.GetFloatByName(this._max_name, this._max_value); + float para = XSingleton.singleton.RandomFloat(floatByName, floatByName2); + entity.AI.AIData.SetFloatByName(this._store_result_name, para); + return true; + } + } +} -- cgit v1.1-26-g67d0