少年修仙传客户端代码仓库
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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using LitJson;
 
namespace vnxbqy.UI
{
 
    //查询玩家具体哪一套境界装备,还需优化数据缓存
    public class OtherPlayerEquipModel : Model
    {
 
        int m_SelectedLevel = 0;
        public int selectedLevel {
            get {
                return m_SelectedLevel;
            }
            private set {
                if (this.m_SelectedLevel != value)
                {
                    m_SelectedLevel = value;
                    if (selectedLevelChangeEvent != null)
                    {
                        selectedLevelChangeEvent();
                    }
                }
            }
        }
 
        public int viewPlayerType { get; private set; }
        public int playerId { get; private set; }
        public int playerJob { get; private set; }
        public int playerRealm { get; private set; }
        public int playerVipLevel { get; private set; }
        public int wing { get; private set; }
        public int reikiRootEffectId { get; private set; }
        public int equipLevel { get; private set; }
 
        public event Action selectedLevelChangeEvent;
        Dictionary<int, EquipDetailsGroup> equipDetailsGroups = new Dictionary<int, EquipDetailsGroup>();
 
        public override void Init()
        {
 
        }
 
        public override void UnInit()
        {
        }
 
        public void ViewPlayerEquip(PlayerBriefInfo info)
        {
            this.viewPlayerType = info.viewType;
            this.playerId = info.id;
            this.playerJob = info.job;
            this.playerRealm = info.realm;
            this.playerVipLevel = info.vipLevel;
            this.wing = info.wing;
            this.reikiRootEffectId = info.reikiRootEffectId;
            this.equipLevel = info.equipLevel;
 
            SelectLevel(1);
        }
 
        public void SelectLevel(int level)
        {
            if (equipDetailsGroups.ContainsKey(level))
            {
                selectedLevel = level;
                if (!WindowCenter.Instance.IsOpen<OtherPlayerEquipWin>())
                {
                    WindowCenter.Instance.Open<OtherPlayerEquipWin>();
                }
            }
            else
            {
                if (viewPlayerType >= (int)ViewPlayerType.viewCrossPlayerEquip)
                {
                    //由子服服务器向跨服服务器查询
                    CC002_tagCGViewCrossPlayerInfo sendInfo = new CC002_tagCGViewCrossPlayerInfo();
                    sendInfo.PlayerID = (uint)playerId;
                    sendInfo.EquipClassLV = (byte)level;
                    GameNetSystem.Instance.SendInfo(sendInfo);
                }
                else
                {
                    //本服查询
                    CA212_tagCMViewPlayerInfo sendInfo = new CA212_tagCMViewPlayerInfo();
                    sendInfo.PlayerID = (uint)playerId;
                    sendInfo.EquipClassLV = (byte)level;
                    GameNetSystem.Instance.SendInfo(sendInfo);
                }
            }
        }
 
        public void OnGetEquipDetails(HA719_tagSCPlayerEquipCacheResult info)
        {
            equipDetailsGroups[info.EquipClassLV] = new EquipDetailsGroup(playerJob, info.EquipClassLV, info.ItemData);
            selectedLevel = info.EquipClassLV;
 
            if (!WindowCenter.Instance.IsOpen<OtherPlayerEquipWin>())
            {
                WindowCenter.Instance.Open<OtherPlayerEquipWin>();
            }
        }
 
        public Dictionary<int, EquipBrief> GetEquipBriefs()
        {
            if (equipDetailsGroups.ContainsKey(selectedLevel))
            {
                var equipDetailsGroup = equipDetailsGroups[selectedLevel];
                var equipBriefs = new Dictionary<int, EquipBrief>();
                foreach (var details in equipDetailsGroup.equips.Values)
                {
                    var config = ItemConfig.Get(details.itemId);
                    equipBriefs[config.EquipPlace] = new EquipBrief()
                    {
                        itemId = details.itemId,
                        star = details.star,
                    };
                }
 
                return equipBriefs;
            }
            else
            {
                return null;
            }
        }
 
        public int GetFightPoint()
        {
            if (equipDetailsGroups.ContainsKey(selectedLevel))
            {
                return equipDetailsGroups[selectedLevel].fightPoint;
            }
            else
            {
                return 0;
            }
        }
 
        public EquipAppearance GetEquipAppearance()
        {
            if (equipDetailsGroups.ContainsKey(selectedLevel))
            {
                var equipDetailsGroup = equipDetailsGroups[selectedLevel];
                var equips = equipDetailsGroup.equips;
                var suitLevels = equipDetailsGroup.GetSuitLevels();
                var appearance = new EquipAppearance()
                {
                    job = playerJob,
                    clothes = equips.ContainsKey((int)RoleEquipType.Clothes) ? equips[(int)RoleEquipType.Clothes].itemId : 0,
                    weapon = equips.ContainsKey((int)RoleEquipType.Weapon) ? equips[(int)RoleEquipType.Weapon].itemId : 0,
                    secondary = equips.ContainsKey((int)RoleEquipType.Weapon2) ? equips[(int)RoleEquipType.Weapon2].itemId : 0,
                    wings = wing,
                    isSuit = suitLevels.ContainsKey(EquipSuitType.EightSuit) && suitLevels[EquipSuitType.EightSuit] > 0,
                };
 
                return appearance;
            }
            else
            {
                return default(EquipAppearance);
            }
        }
 
        public ItemTipUtility.CustomEquipInfo GetEquipInfo(int level, int place)
        {
            if (!equipDetailsGroups.ContainsKey(level))
            {
                return default(ItemTipUtility.CustomEquipInfo);
            }
 
            if (!equipDetailsGroups[level].equips.ContainsKey(place))
            {
                return default(ItemTipUtility.CustomEquipInfo);
            }
 
            var details = equipDetailsGroups[level].equips[place];
 
            var equipInfo = new ItemTipUtility.CustomEquipInfo();
            equipInfo.job = playerJob;
            equipInfo.itemId = details.itemId;
            equipInfo.isEquiped = true;
 
            equipInfo.score = details.score;
            equipInfo.legendProperties = details.legendProperties;
            equipInfo.suitPlaces = equipDetailsGroups[level].GetSuitPlaces();
            equipInfo.placeStars = equipDetailsGroups[level].GetPlaceStars();
            equipInfo.suitLevels = equipDetailsGroups[level].GetSuitLevels();
            equipInfo.strengthenLevel = details.strengthenLevel;
            equipInfo.evolveLevel = details.evolveLevel;
            equipInfo.starLevel = details.star;
            equipInfo.equipSkillList = details.equipSkillList;
            equipInfo.trainProperties = details.trainProperties;
 
            var gemHoleActiveStates = new Dictionary<int, bool>();
            gemHoleActiveStates[0] = true;
            gemHoleActiveStates[1] = details.star >= 2;
            gemHoleActiveStates[2] = details.star >= 5;
            gemHoleActiveStates[3] = playerVipLevel >= 6;
 
            equipInfo.gemHoleActiveStates = gemHoleActiveStates;
            equipInfo.gems = new Dictionary<int, int>();
            for (var i = 0; i < details.stones.Count; i++)
            {
                equipInfo.gems[i] = details.stones[i];
            }
 
            return equipInfo;
        }
 
        public SuitInfo GetSuitInfo()
        {
            if (!equipDetailsGroups.ContainsKey(selectedLevel))
            {
                return default(SuitInfo);
            }
 
            var suitInfo = new SuitInfo();
            suitInfo.job = playerJob;
            suitInfo.level = selectedLevel;
            suitInfo.placeStars = equipDetailsGroups[selectedLevel].GetPlaceStars();
            suitInfo.suitLevels = equipDetailsGroups[selectedLevel].GetSuitLevels();
 
            return suitInfo;
        }
 
        public void Clear()
        {
            selectedLevel = 0;
            equipDetailsGroups.Clear();
        }
 
        public struct EquipBrief
        {
            public int itemId;
            public int star;
        }
 
        public class EquipDetails
        {
            public int itemId;
            public int score;
            public int star;
            public int strengthenLevel;
            public int evolveLevel;
            public List<int> stones = new List<int>();
            public int trainLevel;
            public List<Int2> trainProperties = new List<Int2>();
            public List<Int2> legendProperties = new List<Int2>();
            public List<int> equipSkillList = new List<int>();
 
            public EquipDetails(JsonData serverInfo)
            {
                itemId = (int)serverInfo["ItemID"];
                star = serverInfo.Keys.Contains("Star") ? (int)serverInfo["Star"] : 0;
                strengthenLevel = serverInfo.Keys.Contains("PlusLV") ? (int)serverInfo["PlusLV"] : 0;
                evolveLevel = serverInfo.Keys.Contains("EvolveLV") ? (int)serverInfo["EvolveLV"] : 0;
 
                if (serverInfo.Keys.Contains("Stone"))
                {
                    var stoneJson = serverInfo["Stone"];
                    for (int i = 0; i < stoneJson.Count; i++)
                    {
                        stones.Add((int)stoneJson[i]);
                    }
                }
 
                if (serverInfo.Keys.Contains("Wash"))
                {
                    var washJson = serverInfo["Wash"];
                    trainLevel = (int)washJson["LV"];
 
                    var washValueJson = washJson["Value"];
                    var config = ItemConfig.Get(itemId);
                    var trainType = EquipTrainModel.GetTrainType(config.EquipPlace);
                    var trainData = EquipWashConfig.Get(trainType, trainLevel);
 
                    trainProperties.Add(new Int2(trainData.config.attType1, (int)washValueJson[0]));
                    trainProperties.Add(new Int2(trainData.config.attType2, (int)washValueJson[1]));
                    //trainProperties.Add(new Int2(trainData.config.attType3, (int)washValueJson[2]));
                }
                else
                {
                    var config = ItemConfig.Get(itemId);
                    var trainType = EquipTrainModel.GetTrainType(config.EquipPlace);
                    var trainData = EquipWashConfig.Get(trainType, 1);
 
                    trainProperties.Add(new Int2(trainData.config.attType1, 0));
                    trainProperties.Add(new Int2(trainData.config.attType2, 0));
                    trainProperties.Add(new Int2(trainData.config.attType3, 0));
                }
 
                Dictionary<int, List<int>> userData = null;
                if (serverInfo.Keys.Contains("UserData"))
                {
                    userData = ConfigParse.Analysis(serverInfo["UserData"].ToString());
                    if (userData.ContainsKey((int)ItemUseDataKey.legendAttrID) && userData.ContainsKey((int)ItemUseDataKey.legendAttrValue))
                    {
                        var count = Mathf.Min(userData[(int)ItemUseDataKey.legendAttrID].Count, userData[(int)ItemUseDataKey.legendAttrValue].Count);
                        for (int i = 0; i < count; i++)
                        {
                            legendProperties.Add(new Int2(userData[(int)ItemUseDataKey.legendAttrID][i], userData[(int)ItemUseDataKey.legendAttrValue][i]));
                        }
                    }
                    if (userData.ContainsKey((int)ItemUseDataKey.equipSkills))
                    {
                        equipSkillList = userData[(int)ItemUseDataKey.equipSkills];
                    }
                }
 
                var legendIds = new List<int>();
                var legendValues = new List<int>();
                foreach (var property in legendProperties)
                {
                    legendIds.Add(property.x);
                    legendValues.Add(property.y);
                }
 
                this.score = ItemLogicUtility.Instance.GetEquipScore(itemId, userData);
            }
 
        }
 
        public class EquipDetailsGroup
        {
            public readonly int job;
            public readonly int level = 0;
            public readonly int fightPoint = 0;
            public Dictionary<int, EquipDetails> equips = new Dictionary<int, EquipDetails>();
 
            public EquipDetailsGroup(int job, int level, string equipInfo)
            {
                this.job = job;
                this.level = level;
                var json = JsonMapper.ToObject(equipInfo);
                foreach (var key in json.Keys)
                {
                    var serverPlace = 0;
                    int.TryParse(key, out serverPlace);
                    if (serverPlace == 0)
                    {
                        continue;
                    }
 
                    var equipPosition = EquipSet.ServerPlaceToClientPlace(serverPlace);
                    equips[equipPosition.y] = new EquipDetails(json[key]);
                }
 
                var equipInfos = new List<EquipFightPower.EquipInfo>();
                foreach (var equip in equips.Values)
                {
                    equipInfos.Add(new EquipFightPower.EquipInfo()
                    {
                        itemId = equip.itemId,
                        score = equip.score,
                        evolveLevel = equip.evolveLevel,
                        strengthenLevel = equip.strengthenLevel,
                        starLevel = equip.star,
                        stones = equip.stones,
                        trainProperties = equip.trainProperties,
                    });
                }
 
                fightPoint = EquipFightPower.Instance.CalculatePower(this.job, this.level, equipInfos);
            }
 
            public Dictionary<int, int> GetPlaceStars()
            {
                var places = new Dictionary<int, int>();
                foreach (var item in equips)
                {
                    if (ItemLogicUtility.Instance.IsSuitEquip(item.Value.itemId))
                    {
                        places[item.Key] = item.Value.star;
                    }
                    else
                    {
                        places[item.Key] = -1;
                    }
                }
 
                return places;
            }
 
            public List<int> GetSuitPlaces()
            {
                var places = new List<int>();
                foreach (var item in equips)
                {
                    if (ItemLogicUtility.Instance.IsSuitEquip(item.Value.itemId))
                    {
                        places.Add(item.Key);
                    }
                }
 
                return places;
            }
 
            public Dictionary<EquipSuitType, int> GetSuitLevels()
            {
                var stars = new List<int>();
                var suitCount = 0;
                foreach (var item in equips)
                {
                    if (item.Key > 8)
                    {
                        continue;
                    }
 
                    if (ItemLogicUtility.Instance.IsSuitEquip(item.Value.itemId))
                    {
                        suitCount++;
                    }
 
                    var star = item.Value.star;
                    stars.Add(star);
                }
 
                stars.Sort((int x, int y) => { return -x.CompareTo(y); });
 
                var twoSuitLevel = (suitCount >= 2 && stars.Count >= 2) ? stars[1] : -1;
                var fiveSuitLevel = (suitCount >= 5 && stars.Count >= 5) ? stars[4] : -1;
                var eightSuitLevel = (suitCount >= 8 && stars.Count >= 8) ? stars[7] : -1;
 
                return new Dictionary<EquipSuitType, int>() {
                    { EquipSuitType.TwoSuit, twoSuitLevel },
                    { EquipSuitType.FiveSuit, fiveSuitLevel},
                    {EquipSuitType.EightSuit, eightSuitLevel },
                };
            }
 
        }
 
        public struct PlayerBriefInfo
        {
            public int viewType;
            public int id;
            public int job;
            public int realm;
            public int vipLevel;
            public int wing;
            public int reikiRootEffectId;
            public int equipLevel;
        }
 
        public struct SuitInfo
        {
            public int level;
            public int job;
            public Dictionary<int, int> placeStars;
            public Dictionary<EquipSuitType, int> suitLevels;
        }
 
    }
 
}