少年修仙传客户端代码仓库
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
using System.Collections.Generic;
using UnityEngine;
using vnxbqy.UI;
 
public class GA_NpcFightZZPlayer : GActorPlayerBase, IOtherSelectable
{
    public class DungeonHelpInfo
    {
        public uint objID;
        public uint playerID;
        public byte job;
    }
 
    public static List<uint> s_UnCreateObjIDList = new List<uint>();
 
    private H0406_tagNPCAppear m_H0406;
    private CmdManager m_CmdManager;
 
    public static int cacheMapDataId;
 
    protected override void OnInit(GameNetPackBasic package)
    {
        base.OnInit(package);
 
        m_H0406 = package as H0406_tagNPCAppear;
 
        if (m_H0406 == null)
        {
            return;
        }
 
        CapsuleCollider _capCollider = Root.AddMissingComponent<CapsuleCollider>();
        _capCollider.height = 1.2f;
        _capCollider.center = new Vector3(0, .6f, 0);
        _capCollider.radius = .4f;
 
        Evt_PlayerClick _evtClick = Root.AddMissingComponent<Evt_PlayerClick>();
        _evtClick.ownerSID = ServerInstID;
 
        // 初始化坐标
        AdjustPos(m_H0406.PosX, m_H0406.PosY);
 
        ActorInfo.moveSpeed = 500f / m_H0406.Speed;
        ActorInfo.atkSpeed = 1;
 
        // -------------------------------------------------------------------------
        // -------------------------------------------------------------------------
        // -------------------------------------------------------------------------
        // -------------------------------------------------------------------------
 
        m_CmdManager = new CmdManager();
 
        // Debug.LogFormat("-------- 关于助战类型的Init: {0}", m_H0406.ObjID);
 
        if (!s_UnCreateObjIDList.Contains(m_H0406.ObjID))
        {
            var _valueInfo = LocalSave.GetString("GA_NpcFightZZPlayer_" + m_H0406.ObjID);
            if (!string.IsNullOrEmpty(_valueInfo))
            {
                string[] _values = _valueInfo.Split('|');
                int _playerId = int.Parse(_values[0]);
 
                //Debug.LogFormat("-------- _playerId: " + _playerId);
 
                SyncHelpBattle(_playerId);
            }
        }
    }
 
    public void SyncHelpBattle(int playerID)
    {
        if (m_ViewPlayerData == null && (playerID > 100))
        {
            //Debug.LogFormat("没有: {0} 信息数据, 这里获取", playerID);
            RoleParticularModel.OnRevPackage += OnRevA705;
            ModelCenter.Instance.GetModel<RoleParticularModel>().ViewPlayerCacheData(playerID, (int)ViewPlayerType.viewPlayerDataZZ);
 
        }
        else
        {
            SyncHelpPlayerInfo();
        }
    }
 
    public void SyncHelpPlayerInfo()
    {
        var _valueInfo = LocalSave.GetString("GA_NpcFightZZPlayer_" + m_H0406.ObjID);
        string[] _values = _valueInfo.Split('|');
        int _playerId = int.Parse(_values[0]);
 
        int _clothesId = -1;
        int _weaponId = -1;
        int _secondaryId = -1;
        int _wingId = -1;
 
        // 读取配置表
        if (_playerId >= 1 && _playerId <= 100)
        {
            if (PlayerDatas.Instance.baseData.MapID == 31110)
            {
                cacheMapDataId = PlayerDatas.Instance.baseData.MapID * 10 + PlayerDatas.Instance.baseData.realmLevel;
            }
            else
            {
                if (cacheMapDataId <= 0)
                {
                    cacheMapDataId = PlayerDatas.Instance.baseData.MapID * 10 + PlayerDatas.Instance.baseData.dungeonLineId;
                }
            }
            var _config = DungeonHelpBattleConfig.Get(cacheMapDataId);
 
            ActorInfo.LV = (ushort)_config.RobotLV;
            ActorInfo.Job = byte.Parse(_values[1]);
            ActorInfo.face = AvatarHelper.GetAvatarDefaultID(ActorInfo.Job);
            ActorInfo.facePic = AvatarHelper.GetAvatarFrameDefaultID(ActorInfo.Job);
            ActorInfo.PlayerName = NPCConfig.Get((int)m_H0406.NPCID).charName;
            ActorInfo.Hp = m_H0406.NPCHP + m_H0406.NPCHPEx * Constants.ExpPointValue;
            ActorInfo.MaxHp = m_H0406.MaxHP + m_H0406.MaxHPEx * Constants.ExpPointValue;
            ActorInfo.familyID = 0;
            ActorInfo.familyName = "";
            ActorInfo.realm = (uint)_config.RobotRealmLV;
            JobSetup = JobSetupConfig.Get(ActorInfo.Job);
 
            var _jsonData = LitJson.JsonMapper.ToObject(_config.RobotCloth);
            var _jobJson = _jsonData[_values[1]];
            if (_jobJson.Count > 0)
            {
                _clothesId = (int)_jobJson[0];
                _weaponId = (int)_jobJson[1];
                _secondaryId = (int)_jobJson[2];
                _wingId = (int)_jobJson[3];
            }
        }
        else
        {
            if (m_ViewPlayerData == null)
            {
                Debug.LogError("异常!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!: " + _playerId);
            }
 
            ActorInfo.LV = (ushort)m_ViewPlayerData.rolePropData.LV;
            ActorInfo.Job = (byte)m_ViewPlayerData.rolePropData.Job;
            ActorInfo.face = (int)m_ViewPlayerData.rolePropData.Face;
            ActorInfo.facePic = (int)m_ViewPlayerData.rolePropData.FacePic;
            ActorInfo.PlayerName = m_ViewPlayerData.rolePropData.Name;
            ActorInfo.familyID = (uint)m_ViewPlayerData.rolePropData.FamilyID;
            ActorInfo.familyName = m_ViewPlayerData.rolePropData.FamilyName;
            ActorInfo.Hp = m_H0406.NPCHP + m_H0406.NPCHPEx * Constants.ExpPointValue;
            ActorInfo.MaxHp = m_H0406.MaxHP + m_H0406.MaxHPEx * Constants.ExpPointValue;
            ActorInfo.realm = (uint)m_ViewPlayerData.rolePropData.RealmLV;
 
            JobSetup = JobSetupConfig.Get(ActorInfo.Job);
 
            _clothesId = m_ViewPlayerData.GetItemId(RoleEquipType.Clothes);
            _weaponId = m_ViewPlayerData.GetItemId(RoleEquipType.Weapon);
            _secondaryId = m_ViewPlayerData.GetItemId(RoleEquipType.Weapon2);
            _wingId = m_ViewPlayerData.GetItemId(RoleEquipType.Wing);
        }
 
        //Debug.LogFormat("Name: {0}", ActorInfo.PlayerName);
        //Debug.LogFormat("_clothesId: {0}, _weaponId: {1}, _secondaryId: {2}, _wingId: {3}", _clothesId, _weaponId, _secondaryId, _wingId);
 
        if (_clothesId <= 0)
        {
            SwitchClothes(0);
        }
        else
        {
            SwitchClothes((uint)_clothesId);
        }
 
        if (_weaponId > 0)
        {
            SwitchWeapon((uint)_weaponId);
        }
        else
        {
            SwitchWeapon(0);
        }
 
        if (_secondaryId > 0)
        {
            SwitchSecondary((uint)_secondaryId);
        }
        else
        {
            SwitchSecondary(0);
        }
 
        if (_wingId > 0)
        {
            SwitchWing((uint)_wingId);
        }
        else
        {
            SwitchWing(0);
        }
 
        RequestName();
 
        IdleImmediate();
    }
 
    private RoleParticularModel.ViewPlayerData m_ViewPlayerData;
 
    private void OnRevA705(int viewType, int playerID, RoleParticularModel.ViewPlayerData data)
    {
        if (viewType != (int)ViewPlayerType.viewPlayerDataZZ)
        {
            return;
        }
        var _valueInfo = LocalSave.GetString("GA_NpcFightZZPlayer_" + m_H0406.ObjID);
        if (string.IsNullOrEmpty(_valueInfo))
        {
            return;
        }
        string[] _values = _valueInfo.Split('|');
        int _playerId = int.Parse(_values[0]);
        if (playerID != _playerId)
        {
            return;
        }
        // Debug.Log("延迟获取了数据: id为 " + package.PlayerID);
        RoleParticularModel.OnRevPackage -= OnRevA705;
 
        m_ViewPlayerData = data;
 
        SyncHelpPlayerInfo();
    }
 
    protected sealed override void OnUpdate()
    {
        if (m_CmdManager != null)
        {
            m_CmdManager.Update();
        }
    }
 
    protected sealed override void OnUnit()
    {
        base.OnUnit();
 
        RoleParticularModel.OnRevPackage -= OnRevA705;
        m_H0406 = null;
        m_CmdManager = null;
        m_ViewPlayerData = null;
    }
 
    public override void Destroy()
    {
    }
 
    public override void OnHorse(byte upOrDown)
    {
 
    }
 
    public override void RefreshLifeBar(ulong value)
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero != null && _hero.SelectTarget == this)
        {
            if (GA_Player.s_OnRefreshLife != null)
            {
                GA_Player.s_OnRefreshLife(ServerInstID, ActorInfo.RealHp, ActorInfo.RealMaxHp);
            }
        }
    }
 
    public override void RequestName()
    {
        ReleaseName();
        if (MovingState == E_MovingState.Ride)
        {
            m_HeadUpName = HeadUpName.RequireHeadUpName(HeadUpName.Pattern.Player, MP_Name1, 0, CameraController.Instance.CameraObject);
        }
        else
        {
            m_HeadUpName = HeadUpName.RequireHeadUpName(HeadUpName.Pattern.Player, MP_Name, 0, CameraController.Instance.CameraObject);
        }
 
        m_HeadUpName.SetPlayerInfo(new HeadUpName.PlayerInfo()
        {
            realm = ActorInfo.realm,
            title = ActorInfo.titleID,
            name = ActorInfo.PlayerName,
            alliance = ActorInfo.familyName,
        });
        RefreshShediaoEffect(ActorInfo.titleID);
    }
 
    protected override void OnPutonClothes(uint clothesItemID, GameObject clothed)
    {
        clothed.layer = LayerUtility.Player;
 
        SkinnedMeshRenderer _renderer = clothed.GetComponentInChildren<SkinnedMeshRenderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
 
    protected override void OnPutonSecondary(uint secondaryItemID, GameObject secondary)
    {
        Renderer _renderer = secondary.GetComponentInChildren<Renderer>();
        if (_renderer)
        {
            _renderer.gameObject.SetLayer(LayerUtility.Player, false);
        }
    }
 
    protected override void OnPutonWeapon(uint weaponItemID, GameObject weapon)
    {
        Renderer _renderer = weapon.GetComponentInChildren<Renderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
 
    protected override void OnPutonWing(uint wingItemID, GameObject wing)
    {
        SkinnedMeshRenderer _renderer = wing.GetComponentInChildren<SkinnedMeshRenderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
 
    protected override void OnSwitchHorse(uint horseID, GameObject horse)
    {
    }
 
    public void OnSelect()
    {
        if (CanAtked())
        {
            SelectionManager.Request(SelectionManager.E_Type.Red, this);
        }
        else
        {
            SelectionManager.Request(SelectionManager.E_Type.Green, this);
        }
 
        if (GA_Player.s_OnSelected != null)
        {
            GA_Player.s_OnSelected(ServerInstID, true);
        }
    }
 
    public void OnClick()
    {
        if (ActorInfo.serverDie)
        {
            return;
        }
 
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero == null)
        {
            return;
        }
 
        _hero.LockTarget = this;
        _hero.SelectTarget = this;
    }
 
    public void OnUnSelect()
    {
        SelectionManager.Release(SelectionManager.E_Type.Green);
        SelectionManager.Release(SelectionManager.E_Type.Red);
 
        if (GA_Player.s_OnSelected != null)
        {
            GA_Player.s_OnSelected(ServerInstID, false);
        }
    }
 
    public bool CanBeSelected()
    {
        if (ActorInfo.serverDie)
        {
            return false;
        }
 
        return true;
    }
 
    public void Cmd_0614(H0614_tagUseSkillPos h0614)
    {
        Cmd0614 _cmd = new Cmd0614();
        _cmd.Init(h0614);
        m_CmdManager.Enqueue(_cmd);
    }
 
    public void ClearAllCMD()
    {
        m_CmdManager.Clear();
    }
 
    public override void SyncSuitEffect(bool onOrOff = true)
    {
    }
}