blob: 1ff6470e7f81e166d360d70ff6621600c3f6d845 (
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
|
#if UNITY_EDITOR
using System;
using UnityEngine;
using XUtliPoolLib;
using System.Collections.Generic;
namespace XEditor
{
class XSkillManipulate
{
private XSkillHoster _hoster = null;
private Dictionary<long, XManipulationData> _item = new Dictionary<long, XManipulationData>();
public Dictionary<long, XManipulationData> 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<XSkillHit>();
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
|