少年修仙传客户端代码仓库
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
using System.Collections.Generic;
using vnxbqy.UI;
 
using UnityEngine;
 
public abstract class HeroAI_Data { }
 
public abstract class HeroAI_Base
{
    public static byte stopReason = 0;
 
    private SkillModel m_SkillModel;
    private SkillModel skillModel
    {
        get { return m_SkillModel ?? (m_SkillModel = ModelCenter.Instance.GetModel<SkillModel>()); }
    }
 
    public abstract bool Condition();
    public abstract void Enter();
    public abstract void Update();
    public abstract void Exit();
    public abstract bool IsOver();
 
    protected int xpSkillID = 0;
 
    protected Skill DecideUserSkill(int[] skillList = null, int priorSkillId = -1)
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero == null || !_hero.CanCastSkill())
        {
            return null;
        }
 
        Skill _skill = null;
 
        if (priorSkillId >= 0)
        {
            if (CanCast(priorSkillId, true))
            {
                _skill = _hero.SkillMgr.Get(priorSkillId);
                if (_skill != null)
                {
                    return _skill;
                }
            }
        }
 
        if (skillList != null)
        {
            // 判断是否需要使用哪个攻击技能
            _skill = CanCast(skillList);
        }
 
        if (_skill != null)
        {
            return _skill;
        }
 
        if (_hero.CanCommonAtk())
        {
            int _index = _hero.nextComAtkIndex;
            if (_index == -1)
            {
                _index = 0;
            }
            int _comSkillID = _hero.GetCommonSkillID(_index);
 
            return _hero.SkillMgr.Get(_comSkillID);
        }
 
        return null;
    }
 
    protected Skill CanCast(int[] skillList)
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
 
        int _chkSkillID = -1;
        for (int i = 0; i < skillList.Length; ++i)
        {
            _chkSkillID = SkillHelper.Instance.GetSkillID(skillList[i]);
 
            if (CanCast(_chkSkillID))
            {
                if(ArenaManager.IsArenaClientNotMirrorFight)
                {
                    bool bWork = true;
                    for(int j = 0;j < GeneralDefine.WorkNotSkills.Length;j++)
                    {
                        if (_chkSkillID == GeneralDefine.WorkNotSkills[j])
                            bWork = false;
                    }
                    if(bWork)
                        return _hero.SkillMgr.Get(_chkSkillID);
                }
                else
                {
                    return _hero.SkillMgr.Get(_chkSkillID);
                }
               
            }
        }
 
        return null;
    }
 
    protected bool CanCastActiveUse(int skillID)
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        var _skill = _hero.SkillMgr.Get(skillID);
 
        // 获取英雄真实拥有的技能
        Dictionary<int, PlayerSkillData> _heroSkills = PlayerDatas.Instance.skill.GetAllSkill();
 
        bool _has = false;
        foreach (var _skillData in _heroSkills.Values)
        {
            if (_skillData.skillCfg.SkillTypeID == _skill.skillInfo.config.SkillTypeID)
            {
                _has = true;
                break;
            }
        }
 
        if (!_has)
        {
            return false;
        }
 
        if (StatusMgr.Instance.IsExist(_hero.ServerInstID, skillID))
        {
            return false;
        }
 
        if (!_skill.IsValid())
        {
            return false;
        }
 
        return true;
    }
 
    protected bool CanCast(int skillID, bool userClick = false)
    {
        if (!CanCastActiveUse(skillID))
        {
            return false;
        }
 
        bool _canCast = true;
 
        bool _forceCast = false;
 
        SkillHelper.EffectValue _effectValue;
        if (SkillHelper.Instance.TryGetExpertSkillEvByMainSkillID(skillID, 4093, out _effectValue))
        {
            _forceCast = true;
        }
        var _skillConfig = SkillConfig.Get(skillID);
        // 判断是否是被封禁的技能
        if (!StatusMgr.Instance.CanAttack(PlayerDatas.Instance.PlayerId, _skillConfig) && !_forceCast)
        {
            _canCast = false;
        }
 
        if (skillID == xpSkillID)
        {
            GA_Hero _hero = PlayerDatas.Instance.hero;
 
            if ((!skillModel.AutoUseXp()
             || GeneralDefine.NoXpDungeons.Contains(PlayerDatas.Instance.baseData.MapID)
             || (_hero.SelectTarget != null && _hero.SelectTarget is GActorPlayerBase)) && !userClick)
            {
                _canCast = false;
            }
        }
 
        return _canCast;
    }
 
    protected GActorFight DecideAttackTarget(Vector3 searchCenter, float range, int lockNpcID = -1)
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        GActorFight _target = _hero.SelectTarget as GActorFight;
 
        if (_target == null || !_target.CanAtked() || _target.ActorInfo.serverDie)
        {
            _target = GAMgr.Instance.FindAtkTarget(searchCenter, range, 360, lockNpcID);
        }
 
        if (_target != null && lockNpcID != -1)
        {
            var _npcFight = _target as GActorNpcFight;
            if (_npcFight != null)
            {
                if (_npcFight.NpcConfig.NPCID != lockNpcID)
                {
                    _target = GAMgr.Instance.FindAtkTarget(searchCenter, range, 360, lockNpcID);
                }
            }
        }
 
        return _target;
    }
 
    private PackModel m_PlayerBackModel;
    private PackModel PlayerBackModel
    {
        get
        {
            return m_PlayerBackModel ?? (m_PlayerBackModel = ModelCenter.Instance.GetModel<PackModel>());
        }
    }
 
    protected bool WaitForPickup()
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        DropItemManager.DropObject _obj = null;
        bool _needPickupSelf = true;
        Vector3 _destPosition = _hero.Pos;
 
        DropItem _item = null;
        if (_needPickupSelf = ClientDropItemUtility.Instance.TryGetDropItem(out _item))
        {
            if (_needPickupSelf)
            {
                _destPosition = _item.transform.position;
            }
        }
 
        if (!_needPickupSelf)
        {
            if (_needPickupSelf = DropItemManager.HandupTryGetHeroItem(out _obj))
            {
                // 有掉落物
                // 是否是强制守护不能拾取的
                if (_obj.ownerType != 7)
                {
                    if (DungeonOpenTimeConfig.Has(PlayerDatas.Instance.baseData.MapID)) // 是副本
                    {
                        var _dungeonOpenTime = DungeonOpenTimeConfig.Get(PlayerDatas.Instance.baseData.MapID);
                        if (_dungeonOpenTime.GuardPick == 1)// 守护可以拾取
                        {
                            var _singleModel = PlayerBackModel.GetSinglePack(PackType.Equip);
                            if (_singleModel != null)
                            {
                                // 如果有守护
                                var _equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.Guard));
                                var _guard = PlayerBackModel.GetItemByIndex(PackType.Equip, _equipIndex);
                                if (_guard != null // 有守护
                                 && GeneralDefine.GuardianPickUpID.Contains(_guard.itemId))// 守护有拾取功能
                                {
                                    _needPickupSelf = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        var _singleModel = PlayerBackModel.GetSinglePack(PackType.Equip);
                        if (_singleModel != null)
                        {
                            // 如果有守护
                            var _equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.Guard));
                            var _guard = PlayerBackModel.GetItemByIndex(PackType.Equip, _equipIndex);
                            if (_guard != null // 有守护
                             && GeneralDefine.GuardianPickUpID.Contains(_guard.itemId))// 守护有拾取功能
                            {
                                _needPickupSelf = false;
                            }
                        }
                    }
                }
 
                if (_needPickupSelf)
                {
                    _destPosition = _obj.dropItem.transform.position;
                }
            }
        }
 
        if (_needPickupSelf)
        {
            _hero.StopRush();
            float _chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _destPosition);
            if (_chkDistSqrt > 0.5f)
            {
                _hero.MoveToPosition(_destPosition);
            }
            return true;
        }
        return false;
    }
 
    public static bool IsSkillNeedMove(int tag, E_SkillType skillType)
    {
        E_SkillCastTarget _targetType = (E_SkillCastTarget)(tag / 10);
        E_SkillCastType _castType = (E_SkillCastType)(tag % 10);
 
        if ((_targetType == E_SkillCastTarget.None
          || _targetType == E_SkillCastTarget.Self
          || _targetType == E_SkillCastTarget.SelfAndFriend
          || _castType == E_SkillCastType.None)
         && (skillType != E_SkillType.Attack))
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}