少年修仙传客户端代码仓库
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
using UnityEngine;
using System.Collections.Generic;
 
using vnxbqy.UI;
 
public class GA_PlayerXMZZ : GActorPlayerBase, IOtherSelectable
{
    public struct XmzzItemInfo
    {
        public int id;
        public int place;
    }
 
    public class XmzzTargetInfo
    {
        public byte job;
        public uint playerID;
        public string FamilyName;
        public uint FamilyID;
        public string name;
        public ushort level;
        public ulong hp;
        public ulong maxHp;
        public XmzzItemInfo[] itemDatas;
    }
 
    public static Dictionary<uint, XmzzTargetInfo> xmzzDict = new Dictionary<uint, XmzzTargetInfo>();
 
    private H0406_tagNPCAppear m_H0406;
    private CmdManager m_CmdManager;
 
    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;
 
        XmzzTargetInfo _info = xmzzDict[m_H0406.NPCID];
 
        JobSetup = JobSetupConfig.Get(_info.job);
 
        XmzzItemInfo _itemInfo;
 
        if (_info.itemDatas != null)
        {
            // 因为衣服是所有装备的父节点, 需要预先处理衣服
            for (int i = 0; i < _info.itemDatas.Length; ++i)
            {
                _itemInfo = _info.itemDatas[i];
 
                if (_itemInfo.place == (int)RoleEquipType.Clothes)
                {
                    //m_SuitLevel = 0;
                    //if (_itemInfo.isSuit == 1)
                    //{
                    //    m_SuitLevel = (byte)_itemInfo.suitLevel;
                    //}
                    SwitchClothes((uint)_itemInfo.id);
                    //ChangeEquip(_itemInfo.place, (uint)_itemInfo.id, m_SuitLevel);
                    break;
                }
            }
        }
 
        // 如果没有任何衣服, 则穿上默认装备
        if (ClothesItemID == 0 || ClothesItemID == uint.MaxValue)
        {
            SwitchClothes(0);
        }
 
        if (_info.itemDatas != null)
        {
            for (int i = 0; i < _info.itemDatas.Length; ++i)
            {
                _itemInfo = _info.itemDatas[i];
 
                if (_itemInfo.place == (int)RoleEquipType.Weapon)
                {
                    SwitchWeapon((uint)_itemInfo.id);
                }
                else if (_itemInfo.place == (int)RoleEquipType.Weapon2)
                {
                    SwitchSecondary((uint)_itemInfo.id);
                }
                else if (_itemInfo.place == (int)RoleEquipType.Wing)
                {
                    SwitchWing((uint)_itemInfo.id);
                }
                else if (_itemInfo.place == (int)RoleEquipType.Guard)
                {
                    SwitchGuard((uint)_itemInfo.id);
                }
                else if (_itemInfo.place == (int)RoleEquipType.Mount)
                {
                    ActorInfo.horseItemID = (uint)_itemInfo.id;
                }
 
                //m_SuitLevel = 0;
                //if (_itemInfo.isSuit == 1)
                //{
                //    m_SuitLevel = (byte)_itemInfo.suitLevel;
                //}
 
                //ChangeEquip(_itemInfo.place, (uint)_itemInfo.id, m_SuitLevel);
            }
        }
 
        if (WeaponItemID == 0 || WeaponItemID == uint.MaxValue)
        {
            SwitchWeapon(0);
        }
 
        ActorInfo.LV = _info.level;
        ActorInfo.Job = _info.job;
        ActorInfo.PlayerName = _info.name;
        if (m_H0406.NPCID == 30403001)
        {
            ActorInfo.Hp = _info.hp;
            ActorInfo.MaxHp = _info.maxHp;
        }
        else
        {
            ActorInfo.Hp = m_H0406.NPCHP + m_H0406.NPCHPEx * Constants.ExpPointValue;
            ActorInfo.MaxHp = m_H0406.MaxHP + m_H0406.MaxHPEx * Constants.ExpPointValue;
        }
 
        RequestName();
 
        m_CmdManager = new CmdManager();
 
        IdleImmediate();
    }
 
    public override void Destroy()
    {
    }
 
    protected sealed override void OnUpdate()
    {
        if (m_CmdManager != null)
        {
            m_CmdManager.Update();
        }
    }
    protected sealed override void OnUnit()
    {
        base.OnUnit();
 
        m_H0406 = null;
        m_CmdManager = null;
    }
 
    public sealed override void OnHorse(byte upOrDown)
    {
    }
 
    public sealed 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 sealed 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 sealed override void OnPutonClothes(uint clothesItemID, GameObject clothed)
    {
        clothed.layer = LayerUtility.Player;
 
        SkinnedMeshRenderer _renderer = clothed.GetComponentInChildren<SkinnedMeshRenderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
 
    protected sealed override void OnPutonSecondary(uint secondaryItemID, GameObject secondary)
    {
        Renderer _renderer = secondary.GetComponentInChildren<Renderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
 
    protected sealed override void OnPutonWeapon(uint weaponItemID, GameObject weapon)
    {
        Renderer _renderer = weapon.GetComponentInChildren<Renderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
 
    protected sealed override void OnPutonWing(uint wingItemID, GameObject wing)
    {
        SkinnedMeshRenderer _renderer = wing.GetComponentInChildren<SkinnedMeshRenderer>();
        _renderer.gameObject.SetLayer(LayerUtility.Player, false);
    }
 
    protected sealed override void OnSwitchHorse(uint horseID, GameObject horse)
    {
    }
 
    public sealed override bool CanAtked() { return true; }
 
    public bool CanBeSelected()
    {
        if (ActorInfo.serverDie)
        {
            return false;
        }
 
        return 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 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 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 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)
    {
    }
}