少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
using System.Collections.Generic;
using vnxbqy.UI;
 
using UnityEngine;
 
public static class GAStaticDefine
{
    public const string WeaponBindBoneName = "Bip001 Prop1";
    public readonly static string[] SecondaryBindBoneName = { "Bip001 L Forearm", "Bip001 Prop2" };
    public const string WingBindBoneName = "Bip001 Spine1";
    public const string MountPointBoneName = "Bip001";
 
    public static readonly int State_IdleHash = Animator.StringToHash("Idle_0");
    public static readonly int State_RunHash = Animator.StringToHash("Run_1");
    public static readonly int State_HurtHash = Animator.StringToHash("Hurt_3");
    public static readonly int State_DeadHash = Animator.StringToHash("Dead_4");
    public static readonly int State_StunHash = Animator.StringToHash("Stun_5");
    public static readonly int State_AirIdleHash = Animator.StringToHash("AirIdle_8");
    public static readonly int State_AirRunHash = Animator.StringToHash("AirRun_9");
    public static readonly int State_HorseIdleHash = Animator.StringToHash("HorseIdle_6");
    public static readonly int State_HorseIdle1Hash = Animator.StringToHash("HorseIdle_61");
    public static readonly int State_HorseIdle2Hash = Animator.StringToHash("HorseIdle_62");
    public static readonly int State_HorseIdle3Hash = Animator.StringToHash("HorseIdle_63");
    public static readonly int State_HorseIdle4Hash = Animator.StringToHash("HorseIdle_64");
    public static readonly int State_HorseRunHash = Animator.StringToHash("HorseRun_7");
    public static readonly int State_HorseRun1Hash = Animator.StringToHash("HorseRun_71");
    public static readonly int State_HorseRun2Hash = Animator.StringToHash("HorseRun_72");
    public static readonly int State_HorseRun3Hash = Animator.StringToHash("HorseRun_73");
    public static readonly int State_HorseRun4Hash = Animator.StringToHash("HorseRun_74");
    public static readonly int State_SitDown = Animator.StringToHash("SitDown_100");
    public static readonly int State_Prepare = Animator.StringToHash("Prepare_200");
    public static readonly int State_HurtDown1Hash = Animator.StringToHash("HurtDown_800");
    public static readonly int State_HurtDown2Hash = Animator.StringToHash("HurtDown_801");
    public static readonly int State_RollHash = Animator.StringToHash("Skill_99");
    public static readonly int State_Dance = Animator.StringToHash("Dance");
    public static readonly int State_Transmit = Animator.StringToHash("Transmit");//传功
 
    public static readonly int State_Attack1Hash = Animator.StringToHash("Attack_10");
    public static readonly int State_Attack2Hash = Animator.StringToHash("Attack_11");
    public static readonly int State_Attack3Hash = Animator.StringToHash("Attack_12");
    public static readonly int State_Attack4Hash = Animator.StringToHash("Attack_13");
 
    public static readonly int State_Skill21 = Animator.StringToHash("Skill_21");
    public static readonly int State_Skill22 = Animator.StringToHash("Skill_22");
    public static readonly int State_Skill23 = Animator.StringToHash("Skill_23");
    public static readonly int State_Skill24 = Animator.StringToHash("Skill_24");
    public static readonly int State_Skill25 = Animator.StringToHash("Skill_25");
    public static readonly int State_Skill26 = Animator.StringToHash("Skill_26");
    public static readonly int State_Skill27 = Animator.StringToHash("Skill_27");
    public static readonly int State_Skill28 = Animator.StringToHash("Skill_28");
    public static readonly int State_Skill29 = Animator.StringToHash("Skill_29");
    public static readonly int State_WarnHash = Animator.StringToHash("Warn_300");
    public static readonly int State_CollectHash = Animator.StringToHash("Collect_400");
    public static readonly int State_Open = Animator.StringToHash("Open");
    public static readonly int State_Fly = Animator.StringToHash("Fly_500");
    public static readonly int Param_Action = Animator.StringToHash("Action");
    public static readonly int Param_ActorInstID = Animator.StringToHash("ActorInstID");
    public static readonly int Param_MoveState = Animator.StringToHash("MoveState");
 
    public const int Act_Idle = 0;
    public const int Act_Run = 1;
    public const int Act_Hurt = 3;
    public const int Act_Dead = 4;
    public const int Act_Stun = 5;
    public const int Act_HorseIdle = 6;
    public const int Act_HorseIdle1 = 61;
    public const int Act_HorseIdle2 = 62;
    public const int Act_HorseIdle3 = 63;
    public const int Act_HorseIdle4 = 64;
    public const int Act_HorseRun = 7;
    public const int Act_HorseRun1 = 71;
    public const int Act_HorseRun2 = 72;
    public const int Act_HorseRun3 = 73;
    public const int Act_HorseRun4 = 74;
    public const int Act_HorseIdleTransfer = 666;
    public const int Act_AirIdle = 8;
    public const int Act_AirRun = 9;
    public const int Act_Attack1 = 10;
    public const int Act_Attack2 = 11;
    public const int Act_Attack3 = 12;
    public const int Act_Attack4 = 13;
    public const int Act_Skill1 = 21;
    public const int Act_Skill2 = 22;
    public const int Act_Skill3 = 23;
    public const int Act_Skill4 = 24;
    public const int Act_Skill5 = 25;
    public const int Act_Skill6 = 26;
    public const int Act_Skill7 = 27;
    public const int Act_Skill8 = 28;
    public const int Act_Dazuo = 100;
    public const int Act_Transmit = 150;
    public const int Act_Show = 200;
    public const int Act_Warn = 300;
    public const int Act_Collect = 400;
    public const int Act_HurtDown = 800;
    public const int Act_Roll = 99;
 
    public static Dictionary<uint, uint> HorseItemID2ConfigID = new Dictionary<uint, uint>();
    public static Dictionary<int, uint> NpcID2ServerInstID = new Dictionary<int, uint>();
 
    private static List<mapnpcConfig> s_MapNpcConfigs = null;
    private static List<mapnpcConfig> MapNpcConfigs
    {
        get { return s_MapNpcConfigs ?? (s_MapNpcConfigs = mapnpcConfig.GetValues()); }
    }
 
    private static Dictionary<int, Dictionary<int, NPCLocation>> mapNpcPositions = new Dictionary<int, Dictionary<int, NPCLocation>>();
 
    public static bool TryGetMapNPCLocation(int _npcId, out NPCLocation _position)
    {
        return TryGetMapNPCLocation(_npcId, 0, out _position);
    }
 
    public static bool TryGetMapNPCLocation(int _npcId, int _mapId, out NPCLocation _location)
    {
        if (mapNpcPositions.ContainsKey(_npcId))
        {
            var positions = mapNpcPositions[_npcId];
            if (_mapId == 0)
            {
                if (positions.Count > 0)
                {
                    var enumerator = positions.Values.GetEnumerator();
                    enumerator.MoveNext();
                    _location = enumerator.Current;
                    return true;
                }
            }
            else
            {
                if (positions.ContainsKey(_mapId))
                {
                    _location = positions[_mapId];
                    return true;
                }
            }
        }
 
        var monsterRefreshConfig = MonsterRefreshPointConfig.Get(_npcId);
        if (monsterRefreshConfig != null)
        {
            Dictionary<int, NPCLocation> mapPositions = null;
            if (mapNpcPositions.ContainsKey(_npcId))
            {
                mapPositions = mapNpcPositions[_npcId];
            }
            else
            {
                mapNpcPositions[_npcId] = mapPositions = new Dictionary<int, NPCLocation>();
            }
 
            mapPositions[monsterRefreshConfig.MapId] = _location = new NPCLocation(monsterRefreshConfig.MapId, monsterRefreshConfig.turned, monsterRefreshConfig.Position * 0.5f, monsterRefreshConfig.scope * .5f);
 
            return true;
        }
 
        mapnpcConfig mapNpcConfig = null;
        if (_mapId == 0)
        {
            foreach (var config in MapNpcConfigs)
            {
                if (config.NPCID == _npcId)
                {
                    mapNpcConfig = config;
                    break;
                }
            }
        }
        else
        {
            foreach (var config in MapNpcConfigs)
            {
                if (config.MapID == _mapId && config.NPCID == _npcId)
                {
                    mapNpcConfig = config;
                    break;
                }
            }
        }
 
        if (mapNpcConfig != null)
        {
            Dictionary<int, NPCLocation> mapPositions = null;
            if (mapNpcPositions.ContainsKey(_npcId))
            {
                mapPositions = mapNpcPositions[_npcId];
            }
            else
            {
                mapNpcPositions[_npcId] = mapPositions = new Dictionary<int, NPCLocation>();
            }
 
            var location = new NPCLocation(mapNpcConfig.MapID, mapNpcConfig.NPCFace, GetClientPostionFromHex(mapNpcConfig.HexPosNPCRefreshAreaChaseArea), 1);
            mapPositions[mapNpcConfig.MapID] = _location = location;
            return true;
        }
 
        _location = default(NPCLocation);
        return false;
    }
 
    public static int GetMapIdByNpcId(int _npcId)
    {
        NPCLocation location;
        if (TryGetMapNPCLocation(_npcId, out location))
        {
            return location.mapId;
        }
        else
        {
            return 0;
        }
    }
 
    public static Vector2 GetClientPostionFromHex(string hex)
    {
 
        Vector2 _position;
 
        string[] _values = hex.Split(' ');
 
        string _hex16 = StringUtility.Contact(_values[3],
                                       _values[2],
                                       _values[1],
                                       _values[0]);
 
        _position.x = System.Convert.ToInt32(_hex16, 16) * .5f;
 
        _hex16 = StringUtility.Contact(_values[7],
                                       _values[6],
                                       _values[5],
                                       _values[4]);
 
        _position.y = System.Convert.ToInt32(_hex16, 16) * .5f;
 
        _values = null;
 
        return _position;
    }
 
    public struct NPCLocation
    {
        public int mapId;
        public int face;
        public Vector2 position;
        public float scope;
 
        public NPCLocation(int _mapId, int _face, Vector2 _postion, float _scope)
        {
            mapId = _mapId;
            face = _face;
            position = _postion;
            scope = _scope;
        }
    }
 
    public static void PopHp(GActor caster, GActor target, int attackType, ulong value)
    {
        if (target == null
         || CameraController.Instance == null
         || PlayerDatas.Instance.hero == null)
        {
            return;
        }
        ///** 普通伤害 1*/
        //Normal = 1,
        ///** 恢复 2*/
        //Recovery,
        ///** 反弹伤害 3*/
        //BounceHurt,
        ///** 留血 4*/
        //Bleed,
        ///** 抵御 5*/
        //Parry,
        ///** 连击 6*/
        //DoubleHit,
        ///** 暴击 7*/
        //SuperHit,
        ///** 会心一击 8*/
        //LuckyHit,
        ///** 闪避 9*/
        //Miss,
 
        if (attackType == (int)HurtAttackType.Recovery
            && target is GA_Player && target != PlayerDatas.Instance.hero.SelectTarget)
        {
            return;
        }
 
        // 判断伤血的归属是否为玩家或者玩家的召唤物或者宠物
        //bool _isHurtHero = target.ServerInstID == PlayerDatas.Instance.PlayerId;
        //if (!_isHurtHero)
        //{
 
        //}
        // ---- 判断是否显示
        if ((caster != null// 来源不能为空
          && (caster.ServerInstID == PlayerDatas.Instance.PlayerId // 自己攻击
          || (caster.ActorInfo.ownerSID != 0
           && caster.ActorInfo.ownerSID == PlayerDatas.Instance.PlayerId))) // 或者是自己的宠物或者召唤物攻击  
         || target.ServerInstID == PlayerDatas.Instance.PlayerId// 或者受伤的人是自己    
         || (attackType == (int)HurtAttackType.Recovery
          && (target.ActorType == GameObjType.gotNPC
          || (PlayerDatas.Instance.hero != null && target == PlayerDatas.Instance.hero.SelectTarget)))// npc和当前选中目标的回血显示
         || (caster == null && target.ActorInfo.ownerSID == 0))
        {
            // 决定显示的类型
            int _base = (int)PopUpNum.Pattern.PlayerAttack;
 
            if (caster is GA_Pet)
            {
                _base = (int)PopUpNum.Pattern.PetAttack;
            }
            else if (caster is GA_NpcSummonFight)
            {
                if (caster.ActorInfo.ownerSID == PlayerDatas.Instance.PlayerId)
                {
                    _base = (int)PopUpNum.Pattern.PlayerAttack;
                }
                else
                {
                    _base = (int)PopUpNum.Pattern.EnemyAttack;
                }
            }
            else if (caster is GActorNpcFight)
            {
                _base = (int)PopUpNum.Pattern.EnemyAttack;
            }
 
            if (target is GA_Hero || caster == null)
            {
                _base = (int)PopUpNum.Pattern.EnemyAttack;
            }
 
            var direction = Vector3.up;
            if (caster != null)
            {
                var screenFrom = CameraController.Instance.CameraObject.WorldToScreenPoint(target.Pos);
                var screenTo = CameraController.Instance.CameraObject.WorldToScreenPoint(caster.Pos);
                direction = screenFrom - screenTo;
            }
 
            PopUpNum.Pattern _pattern = (PopUpNum.Pattern)((attackType - 1) * 3);
 
            var camera = CameraController.Instance.CameraObject;
            var mountPoint = (target is GA_NpcFightBoss || target is GA_NpcClientFightBoss) ? target.MP_Stun : target.MP_Name;
 
            var _casterRealm = 0;
            var _targetRealm = 0;
 
            if (caster is GA_Hero)
            {
                if (target is GActorPlayerBase)
                {
                    int[] _grounp = GeneralDefine.RealmGroup;
                    for (int i = 0; i < _grounp.Length; ++i)
                    {
                        if (PlayerDatas.Instance.baseData.realmLevel > _grounp[i])
                        {
                            _casterRealm = i + 1;
                        }
 
                        if (target.ActorInfo.realm > _grounp[i])
                        {
                            _targetRealm = i + 1;
                        }
                    }
                }
                else if (target is GA_NpcFightNorm)
                {
                    _casterRealm = PlayerDatas.Instance.baseData.realmLevel;
                    _targetRealm = (int)target.ActorInfo.realm == 0 ? 99999999 : (int)target.ActorInfo.realm;
                }
            }
            else if (target is GA_Hero)
            {
                if (caster is GActorPlayerBase)
                {
                    int[] _grounp = GeneralDefine.RealmGroup;
                    for (int i = 0; i < _grounp.Length; ++i)
                    {
                        if (caster.ActorInfo.realm > _grounp[i])
                        {
                            _casterRealm = i + 1;
                        }
 
                        if (PlayerDatas.Instance.baseData.realmLevel > _grounp[i])
                        {
                            _targetRealm = i + 1;
                        }
                    }
                }
                else if (caster is GA_NpcFightNorm)
                {
                    _casterRealm = (int)caster.ActorInfo.realm;
                    _targetRealm = PlayerDatas.Instance.baseData.realmLevel;
                }
            }
 
            if (attackType == (int)HurtAttackType.Suppress)
            {
                _casterRealm = 1;
                _targetRealm = 0;
                _pattern = (PopUpNum.Pattern)(((int)HurtAttackType.Normal - 1) * 3);
            }
            else if (attackType == (int)HurtAttackType.Immune)
            {
                _base = (int)PopUpNum.Pattern.PlayerAttack;
            }
 
            var popupInfo = new PopUpNum.PopupInfo()
            {
                pattern = _pattern + _base,
                num = value,
                camera = camera,
                direction = direction,
                target = mountPoint,
                isPlayer = target is GA_Hero,
                realmSuppress = _casterRealm > _targetRealm
            };
 
            PopUpNum.RecordPopup(popupInfo);
 
            //if (caster is GA_Hero)
            //{
            //    Debug.LogFormat("{0} 攻击了 {1} 执行了飘血: {2}", caster.ServerInstID, target.ServerInstID, value);
            //}
        }
    }
}