From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XEditor/XSkillEditor/XSkillManipulate.cs | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Client/Assets/Scripts/XEditor/XSkillEditor/XSkillManipulate.cs (limited to 'Client/Assets/Scripts/XEditor/XSkillEditor/XSkillManipulate.cs') diff --git a/Client/Assets/Scripts/XEditor/XSkillEditor/XSkillManipulate.cs b/Client/Assets/Scripts/XEditor/XSkillEditor/XSkillManipulate.cs new file mode 100644 index 00000000..1ff6470e --- /dev/null +++ b/Client/Assets/Scripts/XEditor/XSkillEditor/XSkillManipulate.cs @@ -0,0 +1,65 @@ +#if UNITY_EDITOR +using System; +using UnityEngine; +using XUtliPoolLib; +using System.Collections.Generic; + +namespace XEditor +{ + class XSkillManipulate + { + private XSkillHoster _hoster = null; + + private Dictionary _item = new Dictionary(); + public Dictionary Set { get { return _item; } } + + public XSkillManipulate(XSkillHoster hoster) + { + _hoster = hoster; + } + + public void Add(long token, XManipulationData data) + { + if (!_item.ContainsKey(token)) + { + _item.Add(token, data); + } + } + + public void Remove(long token) + { + if (token == 0) _item.Clear(); + else + { + _item.Remove(token); + } + } + + public void Update(float deltaTime) + { + XSkillHit[] hits = GameObject.FindObjectsOfType(); + + foreach (XManipulationData data in _item.Values) + { + Vector3 center = _hoster.transform.position + _hoster.transform.rotation * new Vector3(data.OffsetX, 0, data.OffsetZ); + + foreach (XSkillHit hit in hits) + { + Vector3 gap = center - hit.transform.position; gap.y = 0; + float dis = gap.magnitude; + + if (dis < data.Radius && (dis == 0 || Vector3.Angle(-gap, _hoster.transform.forward) <= data.Degree * 0.5f)) + { + float len = data.Force * deltaTime; + + Vector3 dir = gap.normalized; + Vector3 move = dir * Mathf.Min(dis, len); + + hit.transform.Translate(move, Space.World); + } + } + } + } + } +} +#endif \ No newline at end of file -- cgit v1.1-26-g67d0