少年修仙传客户端代码仓库
client_linchunjie
2019-03-04 2a86bfa84ad4ed870703022ea765e29f16d25a08
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using UnityEngine;
 
public class Status_Mocking : Status_Base
{
    private float m_LastUseSkillTime;
 
    public sealed override void Update()
    {
        if (h0605.ObjID != PlayerDatas.Instance.PlayerId)
        {
            return;
        }
 
        GA_Hero _hero = PlayerDatas.Instance.hero;
 
        if (_hero == null
         || !_hero.CanCommonAtk())
        {
            return;
        }
 
        // 攻击间隔中
        if (Time.time - m_LastUseSkillTime
          < (1f / _hero.ActorInfo.atkSpeed) * .8f)
        {
            return;
        }
 
        Skill _skill = _hero.SkillMgr.CurCastSkill;
 
        if (_hero.SkillMgr.DoingPrepareSkill)
        {
            return;
        }
 
        // 判断主角当前是否有技能尚未释放完毕
        if (_skill != null)
        {
            if (!_skill.SkillCompelete)
            {
                return;
            }
        }
 
        int _index = _hero.nextComAtkIndex;
        if (_index == -1)
        {
            _index = 0;
        }
        int _comSkillID = _hero.GetCommonSkillID(_index);
        _skill = _hero.SkillMgr.Get(_comSkillID);
 
        if (_skill == null)
        {
            return;
        }
 
        // 这里需要实时取对象, 因为视野可能导致对象回收
        GActorFight _target = GAMgr.Instance.GetBySID(h0605.OwnerID) as GActorFight;
 
        // 对象是否还存在且为可攻击状态
        if (_target == null
        || !_target.CanAtked())
        {
            return;
        }
 
        // 判断技能范围, 不在可释放范围需要移动至目标
        float _compareDist = _skill.skillInfo.config.AtkDist * .5f;
        float _compareDistSqrt = _compareDist * _compareDist;
 
        // 计算当前和目标的距离
        float _currentDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _target.Pos);
        // 比较距离
        if (_currentDistSqrt > _compareDistSqrt)
        {
            // 移动至目标
            _hero.MoveToTarget(_target, _compareDist);
 
            // 判断是否需要冲锋
            if (_hero.IsNeedRush(_currentDistSqrt))
            {
                _hero.StartRush();
            }
 
            return;
        }
 
        // 停止冲锋逻辑
        _hero.StopRush();
 
        Vector3 _forward = MathUtility.ForwardXZ(_target.Pos, _hero.Pos);
        _hero.destForward = _hero.Forward = _forward;
 
        _hero.Behaviour.DoCommonAttack();
 
        m_LastUseSkillTime = Time.time;
    }
}