少年修仙传客户端代码仓库
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
461
462
463
464
465
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, September 07, 2018
//--------------------------------------------------------
using vnxbqy.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
using UnityEngine;
 
// 关于神兽强化
 
    public class GodBeastModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
{
    public Dictionary<int, int> Absorption_Dic = new Dictionary<int, int>();//获取选择的物品
    public event Action AbsorbEvent;
    public int ItemInde = 0;//物品下标
    public ItemModel Crystal_ItemModel;//当前所选中的水晶物品
    public int ItemPos = 1;//设置弹框的位置索引
    public int ItemPlace = -1;//神兽装备位置信息
    public Dictionary<int, int> QualityLimit = new Dictionary<int, int>();//对应品质所能选择的最大强化等级
    DogzModel Dogz_model;
    DogzModel dogz_model { get { return Dogz_model ?? (Dogz_model = ModelCenter.Instance.GetModel<DogzModel>()); } }
    PackModel _playerPack;
    PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); } }
    public Dictionary<int, Redpoint> GodBeastRedPointDic = new Dictionary<int, Redpoint>();//key装备位置下标(红点)
    private List<int> RedPointLIst = new List<int>();
    private const int Redpoint_key1 = 11202;//神兽强化红点
    public Redpoint redPointStre1 = new Redpoint(112, Redpoint_key1);
    public override void Init()
    {
        if (QualityLimit.Count <= 0)
        {
            string DogzAssist = FuncConfigConfig.Get("DogzAssist").Numerical4;//获取不同品质的神兽强化上限
            QualityLimit = ConfigParse.GetDic<int, int>(DogzAssist);
        }
    }
 
    public void OnBeforePlayerDataInitialize()
    {
        playerPack.itemCntAddEvent -= ItemCntAddAct;
        playerPack.itemCntReduceEvent -= ItemCntReduceAct;
        dogz_model.UpdateAssistDogzEvent -= UpdateAssistDogzEvent;
        FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
        DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent -= MakeItemAnswerEvent;
 
    }
 
    public void OnPlayerLoginOk()
    {       
        DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent += MakeItemAnswerEvent;
        playerPack.itemCntAddEvent += ItemCntAddAct;//物品数量增加
        playerPack.itemCntReduceEvent += ItemCntReduceAct;//物品数量减少
        dogz_model.UpdateAssistDogzEvent += UpdateAssistDogzEvent;
        FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
        SetRedPointID();
        GodBeastRedPoint();
    }
 
    private void MakeItemAnswerEvent(H0721_tagMakeItemAnswer obj)
    {
        if ((int)obj.MakeType == (int)MakeType.DogzEquipPlus)
        {
            GodBeastRedPoint();
        }
    }
 
    private void OnFuncStateChangeEvent(int obj)
    {
        if (obj == 138)
        {
            GodBeastRedPoint();
        }
    }
 
    private void UpdateAssistDogzEvent()
    {
        foreach (var key in GodBeastRedPointDic.Keys)
        {
            GodBeastRedPointDic[key].state = RedPointState.None;
        }
        SetRedPointID();
        GodBeastRedPoint();
    }
 
    private void ItemCntReduceAct(PackType packType, int arg2, int arg3)
    {
        if (packType == PackType.DogzItem || packType == PackType.DogzEquip)
        {
            GodBeastRedPoint();
        }
    }
 
    private void ItemCntAddAct(PackType packType, int arg2, int arg3)
    {
        if (packType == PackType.DogzItem || packType == PackType.DogzEquip)
        {
            GodBeastRedPoint();
        }
    }
 
    public override void UnInit()
    {
 
    }
 
    public void AbsorbEventUpdate()
    {
        if (AbsorbEvent != null)
        {
            AbsorbEvent();
        }
    }
 
    private Dictionary<int, int> AllEnhancedPropertiesDic = new Dictionary<int, int>();//key:为属性编号,value是属性值
    public Dictionary<int, int> AllEnhancedProperties(int GodBeastNumber)//获取整只神兽强化属性
    {
        AllEnhancedPropertiesDic.Clear();
        List<ItemModel> itemModel = dogz_model.GetDogzEquips(GodBeastNumber);
        if (itemModel == null)
        {
            return AllEnhancedPropertiesDic;
        }
        for (int i = 0; i < itemModel.Count; i++)
        {
            ItemModel item = itemModel[i];
            var IudetDogzEquipPlus = item.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
            if (IudetDogzEquipPlus != null)
            {
                int lv = IudetDogzEquipPlus[0];
                if (lv > 0)
                {
                    var DogzEquipConfig = DogzEquipPlusConfig.GetEquipplaceAndLevel(item.config.EquipPlace, lv);
                    int[] AttType = DogzEquipConfig.attType;
                    int[] AttValue = DogzEquipConfig.attValue;
                    for (int j = 0; j < AttType.Length; j++)
                    {
                        if (AllEnhancedPropertiesDic.ContainsKey(AttType[j]))
                        {
                            var value = AllEnhancedPropertiesDic[(AttType[j])];
                            AllEnhancedPropertiesDic[(AttType[j])] = value + AttValue[j];
                        }
                        else
                        {
                            AllEnhancedPropertiesDic.Add(AttType[j], AttValue[j]);
                        }
                    }
                }
            }
        }
        return AllEnhancedPropertiesDic;
    }
    private Dictionary<int, int> SiteEnhancementAttributeDic = new Dictionary<int, int>();//key:为属性编号,value是属性值
    public Dictionary<int, int> SiteEnhancementAttribute(PackType PackTypeGodBeast, int GodBeastIndex)//获取某只神兽身上某个装备属性值
    {
        SiteEnhancementAttributeDic.Clear();
        ItemModel item = playerPack.GetItemByIndex(PackTypeGodBeast, GodBeastIndex);
        if (item == null)
        {
            return SiteEnhancementAttributeDic;
        }
        var IudetDogzEquipPlus = item.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
        if (IudetDogzEquipPlus != null && IudetDogzEquipPlus[0] > 0)
        {
            var DogzEquipConfig = DogzEquipPlusConfig.GetEquipplaceAndLevel(item.config.EquipPlace, IudetDogzEquipPlus[0]);
            int[] AttType = DogzEquipConfig.attType;
            int[] AttValue = DogzEquipConfig.attValue;
            for (int j = 0; j < AttType.Length; j++)
            {
                if (SiteEnhancementAttributeDic.ContainsKey(AttType[j]))
                {
                    SiteEnhancementAttributeDic[(AttType[j])] = AttValue[j];
                }
                else
                {
                    SiteEnhancementAttributeDic.Add(AttType[j], AttValue[j]);
                }
            }
        }
        return SiteEnhancementAttributeDic;
    }
 
    public int DogZBagIndex = 0;//当前强化的装备下标
    public bool IsToggleBool = false;
    public bool IsFullLevel()//是都满级能够继续吸收
    {
        int DogZLV = 0;//获取当前神兽等级
        int DogProficiency = 0;//当前神兽的熟练度
        int SingleProficiency = 0;//单倍熟练度
        int DoubleProficiency = 0;//双倍熟练度
        ItemModel itemModel = playerPack.GetItemByIndex(PackType.DogzEquip, DogZBagIndex);
        if (itemModel == null)
        {
            return false;
        }
        int lv = QualityLimit[itemModel.config.ItemColor];//获取最大强化等级
        var DogzEquipMaxConfig = DogzEquipPlusConfig.GetEquipplaceAndLevel(itemModel.config.EquipPlace, lv);
        var IudetDogzEquipPlus = itemModel.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
 
        if (IudetDogzEquipPlus != null)
        {
            DogZLV = IudetDogzEquipPlus[0];
            DogProficiency = IudetDogzEquipPlus[1];
        }
        if (DogZLV >= lv)
        {
            return true;
        }
        foreach (var key in Absorption_Dic.Keys)
        {
            ItemModel item_Model = playerPack.GetItemByIndex(PackType.DogzItem, key);
            if (item_Model != null)
            {
                if (item_Model.config.Effect1 == 235)
                {
                    var _IudetDogzEquipPlus = item_Model.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
                    SingleProficiency += item_Model.config.EffectValueA1 * Absorption_Dic[key];
                    if (_IudetDogzEquipPlus != null)
                    {
                        SingleProficiency += _IudetDogzEquipPlus[1];
                        DoubleProficiency += item_Model.config.EffectValueA1 + _IudetDogzEquipPlus[1];
                    }
                    else
                    {
                        DoubleProficiency += item_Model.config.EffectValueA1 * 2 * Absorption_Dic[key];
                    }
                }
            }
        }
        if (IsToggleBool)//双倍熟练度
        {
            if (DogProficiency + DoubleProficiency >= DogzEquipMaxConfig.upExpTotal)
            {
                return true;//已满
            }
            else
            {
                return false;//未满
            }
        }
        else//单倍熟练度
        {
            if (DogProficiency + SingleProficiency >= DogzEquipMaxConfig.upExpTotal)
            {
                return true;//已满
            }
            else
            {
                return false;//未满
            }
        }
    }
 
 
    private void SetRedPointID()//设置红点ID
    {
        GodBeastRedPointDic.Clear();
        RedPointLIst.Clear();
        var DogzEquipDict = dogz_model.dogzAssistStateDict;
        foreach (var key in DogzEquipDict.Keys)
        {
            if (DogzEquipDict[key] == 1)
            {
                List<ItemModel> itemModel = dogz_model.GetDogzEquips(key);
                if (itemModel == null)
                {
                    continue;
                }
                for (int i = 0; i < itemModel.Count; i++)
                {
                    int IndexId = itemModel[i].gridIndex;
                    int RedPoint = Redpoint_key1 * 1000 + IndexId;
                    Redpoint redPointStare = new Redpoint(Redpoint_key1, RedPoint);
                    if (!GodBeastRedPointDic.ContainsKey(IndexId))
                    {
                        GodBeastRedPointDic.Add(IndexId, redPointStare);
                        RedPointLIst.Add(IndexId);
                    }
                }
            }
        }
        RedPointLIst.Sort(Compare);
    }
    int Compare(int x, int y)
    {
        ItemModel IindexitemModelx = playerPack.GetItemByIndex(PackType.DogzEquip, x);
        ItemModel IindexitemModely = playerPack.GetItemByIndex(PackType.DogzEquip, y);
        if (IindexitemModelx.config.ItemColor.CompareTo(IindexitemModely.config.ItemColor) != 0)//品质
        {
            return -IindexitemModelx.config.ItemColor.CompareTo(IindexitemModely.config.ItemColor);
        }
        if (IindexitemModelx.config.StarLevel.CompareTo(IindexitemModely.config.StarLevel) != 0)//星级
        {
            return -IindexitemModelx.config.StarLevel.CompareTo(IindexitemModely.config.StarLevel);
        }
        if (IindexitemModelx.config.EquipPlace.CompareTo(IindexitemModely.config.EquipPlace) != 0)//装备位
        {
            return IindexitemModelx.config.EquipPlace.CompareTo(IindexitemModely.config.EquipPlace);
        }
        if (GetLV(IindexitemModelx).CompareTo(GetLV(IindexitemModely)) != 0)//强化等级
        {
            return -GetLV(IindexitemModelx).CompareTo(GetLV(IindexitemModely));
        }
        if (GetProficiency(IindexitemModelx).CompareTo(GetProficiency(IindexitemModely)) != 0)//熟练度
        {
            return -GetProficiency(IindexitemModelx).CompareTo(GetProficiency(IindexitemModely));
        }
        if (IindexitemModelx.score.CompareTo(IindexitemModely.score) != 0)//装备评分
        {
            return -IindexitemModelx.score.CompareTo(IindexitemModely.score);
        }
        return 1;
    }
 
    private int GetLV(ItemModel _ItemModel)
    {
        var IudetDogzEquipPlus = _ItemModel.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
        if (IudetDogzEquipPlus != null)
        {
            return IudetDogzEquipPlus[0];
        }
        return 0;
    }
    private int GetProficiency(ItemModel _ItemModel)
    {
        var IudetDogzEquipPlus = _ItemModel.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
        if (IudetDogzEquipPlus != null)
        {
            return IudetDogzEquipPlus[1];
        }
        return 0;
    }
    public int IndexId = 0;
    private void GodBeastRedPoint()//神兽强化红点
    {
        bool Istrue = false;
        bool IsRedPoint = false;
        int ItemColor = 10;
        var DogzEquipDict = dogz_model.dogzAssistStateDict;
        IndexId = 0;
        foreach (var key in GodBeastRedPointDic.Keys)
        {
            GodBeastRedPointDic[key].state = RedPointState.None;
        }
        int Type = 0;
        foreach (var key in DogzEquipDict.Keys)
        {
            if (DogzEquipDict[key] == 1)
            {
                Type += 1;
                List<ItemModel> itemModel = dogz_model.GetDogzEquips(key);
                if (itemModel == null)
                {
                    return;
                }
                for (int i = 0; i < itemModel.Count; i++)
                {
                    if (itemModel[i].config.ItemColor < ItemColor)//获取最低品质的颜色
                    {
                        ItemColor = itemModel[i].config.ItemColor;
                    }
                    var IudetDogzEquipPlus = itemModel[i].GetUseData((int)ItemUseDataKey.dogzEquipPlus);// 神兽装备强化信息列表 [强化等级, 强化熟练度]
                    if (IudetDogzEquipPlus == null)//判断是否都满级 满级不可亮红点
                    {
                        Istrue = true;
                    }
                    else
                    {
                        if (QualityLimit.ContainsKey(itemModel[i].config.ItemColor) && IudetDogzEquipPlus[0] < (QualityLimit[itemModel[i].config.ItemColor]))
                        {
                            Istrue = true;
                        }
                    }
                }
                if (Istrue)
                {
                    if (playerPack.GetSinglePack(PackType.DogzItem) == null)
                    {
                        return;
                    }
                    Dictionary<int, ItemModel> BackpackDic = playerPack.GetSinglePack(PackType.DogzItem).GetAllItems();
                    int _ItemColor = 10;
                    foreach (var keyBack in BackpackDic.Keys)
                    {
                        var itemModelBack = BackpackDic[keyBack];
                        if (itemModelBack.config.Type == 70)//有神兽水晶时的红点
                        {
                            IsRedPoint = true;
                        }
                        if (itemModelBack.config.ItemColor < _ItemColor)
                        {
                            _ItemColor = itemModelBack.config.ItemColor;
                        }
                    }
                    if (Type >= dogz_model.curSumAssistNum && ItemColor > _ItemColor)//出战神兽已满,且神兽背包有品质低于已助战神兽品质颜色时
                    {
                        IsRedPoint = true;
                    }
                }
            }
        }
 
        if (IsRedPoint)
        {
            int Lv = 100;
            for (int i = 0; i < RedPointLIst.Count; i++)
            {
                ItemModel _itemModel = playerPack.GetItemByIndex(PackType.DogzEquip, RedPointLIst[i]);
                
                if (_itemModel == null)
                {
                    continue;
                }
                int MaxLv = QualityLimit[_itemModel.config.ItemColor];//获取最大强化等级
                var _IudetDogzEquipPlus = _itemModel.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
 
                if (_IudetDogzEquipPlus != null)
                {
                    if (_IudetDogzEquipPlus[0]<MaxLv && _IudetDogzEquipPlus[0] < Lv)
                    {
                        Lv = _IudetDogzEquipPlus[0];
                        IndexId = RedPointLIst[i];
                    }
                }
                else
                {
                    if (0 < Lv)
                    {
                        Lv = 0;
                        IndexId = RedPointLIst[i];
                    }
                }
            }
            if (GodBeastRedPointDic.ContainsKey(IndexId))
            {
                GodBeastRedPointDic[IndexId].state = RedPointState.Simple;
            }
        }
 
    }
 
    public bool IsNeedEquipment()//是否有极品装备需要弹框
    {
        bool IsBool = false;
        foreach (var key in Absorption_Dic.Keys)
        {
            ItemModel itemModel = playerPack.GetItemByIndex(PackType.DogzItem, key);
            if (itemModel != null)
            {
                if (itemModel.config.EquipPlace > 0 && itemModel.config.ItemColor >= 5)
                {
                    IsBool = true;
                }
            }
 
        }
        return IsBool;
    }
}