少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
using System;
using vnxbqy.UI;
using UnityEngine;
 
public class Status_Mocking : Status_Base
{
    private float m_LastUseSkillTime;
    private int m_UseClickSkill = -1;
 
    public override void Init(uint sid, int skillId, uint srcSid, int type, int lastTime)
    {
        base.Init(sid, skillId, srcSid, type, lastTime);
        m_UseClickSkill = -1;
        HeroBehaviour.OnUserClickSkill += OnUserClickSkill;
    }
 
    private void OnUserClickSkill(int skillId)
    {
        m_UseClickSkill = skillId;
    }
 
    public override void UnInit(uint objID, byte buffType)
    {
        base.UnInit(objID, buffType);
 
        HeroBehaviour.OnUserClickSkill -= OnUserClickSkill;
    }
 
    public sealed override void Update()
    {
        if (Sid != 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;
            }
        }
 
        _skill = null;
 
        if (m_UseClickSkill != -1)
        {
            int _skillId;
            var _tsModel = ModelCenter.Instance.GetModel<TreasureSkillModel>();
            if (_tsModel.TryGetExpertSkill(m_UseClickSkill, out _skillId))
            {
                int _level = 0;
                if (_tsModel.TryGetExpertActiveLevel(_skillId, out _level))
                {
                    _skillId += (_level - 1);
                }
                var _skillInfo = SkillHelper.Instance.Get(_skillId);
                SkillHelper.EffectValue _effectValue;
                if (_skillInfo.effectValue.TryGetValue(4093, out _effectValue))
                {
                    _skill = _hero.SkillMgr.Get(_skillId);
                }
            }
            m_UseClickSkill = -1;
        }
 
        if (_skill == null)
        {
            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(CasterSid) 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;
 
        if (_skill.skillInfo.config.FuncType == (int)E_SkillFuncType.NormalAttack)
        {
            _hero.Behaviour.DoCommonAttack();
        }
        else
        {
            _hero.Behaviour.DoAttack(_skill);
        }
 
        m_UseClickSkill = -1;
        m_LastUseSkillTime = Time.time;
    }
}