少年修仙传客户端代码仓库
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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, March 11, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
 
namespace vnxbqy.UI
{
    //装备强化
    public struct EquipStrength
    {
        public int EquipIndex;//强化部位
        public int StrengthLevel;//等级
        public int Exp;//经验
        public int EvolveLV;//进化等级
        public int Type;//强化类型
 
    }
 
    public class EquipTypeClass
    {
        public int AttType;//属性类型
        public int AttValue;//属性值
        public string StrName;//属性名
    }
    public class EquipMaxLvClass
    {
        public int MaxLv;
        public int MaxStar;
    }
 
    public class EquipPlusEvolveClass
    {
        public int EquipType;//装备类型
        public int EvolveLV;//进化等级
        public int NeedPlusLV;//需要强化等级
        public int CostItemID;//所需物品ID
        public int CostItemCount;//所需物品数量
        public ItemConfig Item;
        public int AttrType;
        public string AttrValue;
        public string AttrName;
    }
 
    
    public class EquipStrengthModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
        public Dictionary<int, EquipStrength> EquipStrengthDic = new Dictionary<int, EquipStrength>();//强化数据
        public Dictionary<int, Dictionary<int, int>> EquipLevelMaxDic = new Dictionary<int, Dictionary<int, int>>();//强化类型的最大等级上限
        static Dictionary<int, int> PartTypeDic = new Dictionary<int, int>();//强化的部位类型
        public Dictionary<int, int> EvolutionTypeMaxDic = new Dictionary<int, int>();
        Dictionary<int, int> PlusMasterDict = new Dictionary<int, int>();
 
        public List<EquipSetSelect> EquipSetList = new List<EquipSetSelect>();
 
        public event Action EquipStrengthUpdate;//强化数据刷新
        public event Action<int> EquipStrengthLvUpdate;//强化升级成功
        public event Action EquipStrngthEvolutionLv;//进阶成功
        public event Action SelectEquipRefresh;//二级页签刷新
        public event Action SelectLevelRefresh;//一级页签刷新
 
        public event Action StrengthMasterFresh;//强化大师
 
        public List<int> equipPlaces { get; private set; }
 
        //public Int3[] redpointLimits;
 
        private bool isChangeBool = true;
        public bool IsChangeBool {
            get { return isChangeBool; }
            set { isChangeBool = value; }
        }
        private int selectLevel = 0;
        public int SelectLevel//装备类别
        {
            get { return selectLevel; }
            set {
                if (selectLevel != value)
                {
                    selectLevel = value;
                    if (SelectLevelRefresh != null)
                    {
                        SelectLevelRefresh();
                    }
                }
            }
        }
        private int m_SelectEquipPlace = -1;//装备部位
        public int SelectEquipPlace//装备类别
        {
            get { return m_SelectEquipPlace; }
            set {
                if (m_SelectEquipPlace != value)
                {
                    m_SelectEquipPlace = value;
                    if (SelectEquipRefresh != null)
                    {
                        SelectEquipRefresh();
                    }
                }
            }
        }
 
        public Int2 jumpEquipPosition { get; set; }
 
        public bool isServerPrepare { get; private set; }
 
        public readonly Redpoint redpoint = new Redpoint(106, 10601);
        public static int REDPOINTBASE = 106010000;
 
        Dictionary<int, Redpoint> m_EquipSetRedpoints = new Dictionary<int, Redpoint>();
        Dictionary<int, EquipStrengthRedpoint> m_EquipStrengthRedpoints = new Dictionary<int, EquipStrengthRedpoint>();
        public Dictionary<int, Redpoint> m_EquipSetMasterRedpoints = new Dictionary<int, Redpoint>();
 
        Dictionary<Int2, Redpoint> equipPositionRed = new Dictionary<Int2, Redpoint>();
 
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
        EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
 
        public override void Init()
        {
            var strengthenLevelLimit = FuncConfigConfig.Get("StrengthenLevelLimit").Numerical1;
            PartTypeDic = ConfigParse.GetDic<int, int>(strengthenLevelLimit);
            InitEquipLevelMax();
            GetEvolutionTypeMax();
 
            var funcConfig = FuncConfigConfig.Get("StrengthenRedPointLevel");
            var array = funcConfig.Numerical1.Split('|');
            //redpointLimits = new Int3[array.Length];
            //for (int i = 0; i < array.Length; i++)
            //{
            //    Int3.TryParse(array[i], out redpointLimits[i]);
            //}
 
            equipPlaces = new List<int>(12);
            for (int i = 1; i <= 12; i++)
            {
                equipPlaces.Add(i);
            }
 
            var configs = EquipControlConfig.GetValues();
            var totalEquipLevels = new List<int>();
            foreach (var item in configs)
            {
                var level = item.level;
                if (!totalEquipLevels.Contains(level))
                {
                    totalEquipLevels.Add(level);
                }
            }
 
            foreach (var level in totalEquipLevels)
            {
                var equipSetRedpointBase = REDPOINTBASE++;
                m_EquipSetRedpoints[level] = new Redpoint(redpoint.id, equipSetRedpointBase);
                foreach (var place in equipPlaces)
                {
                    var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
                    if (!m_EquipStrengthRedpoints.ContainsKey(packIndex))
                    {
                        EquipStrengthRedpoint _redpoint = new EquipStrengthRedpoint(equipSetRedpointBase);
                        m_EquipStrengthRedpoints.Add(packIndex, _redpoint);
                    }
                }
                m_EquipSetMasterRedpoints[level] = new Redpoint(equipSetRedpointBase, equipSetRedpointBase+5000);
            }
 
            packModel.refreshItemCountEvent += RefreshItemCountEvent;
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
            PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
            equipModel.OnSelectFuncSetEvent += OnSelect;
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            isServerPrepare = false;
            EquipStrengthDic.Clear();
            PlusMasterDict.Clear();
 
            foreach (var instance in EquipSetList)
            {
                GameObject.Destroy(instance.gameObject);
            }
            EquipSetList.Clear();
 
        }
 
        public void OnPlayerLoginOk()
        {
            UpdateRedpoint();
            isServerPrepare = true;
        }
 
        public override void UnInit()
        {
            packModel.refreshItemCountEvent -= RefreshItemCountEvent;
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
            PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
            equipModel.OnSelectFuncSetEvent -= OnSelect;
        }
 
        private void OnSelect(int equipLevel)
        {
            if (SelectLevel == equipLevel)
            {
                return;
            }
            else
            {
                SelectLevel = equipLevel;
            }
        }
 
        private void PlayerDataRefreshEvent(PlayerDataType dataType)
        {
            if (dataType == PlayerDataType.Silver
                || dataType == PlayerDataType.LV)
            {
                if (isServerPrepare)
                {
                    UpdateRedpoint();
                }
            }
        }
 
        private void OnFuncStateChangeEvent(int id)
        {
            if (id == (int)FuncOpenEnum.Strength)
            {
                if (isServerPrepare)
                {
                    UpdateRedpoint();
                }
            }
        }
 
        private void RefreshItemCountEvent(PackType packType, int arg2, int itemId)
        {
            if (packType == PackType.Item)
            {
                if (isServerPrepare)
                {
                    UpdateRedpoint();
                }
            }
        }
 
        public void UpdateEuipPartPlusInfo(HA3B3_tagMCEquipPartPlusInfo info)
        {
            for (int i = 0; i < info.Count; i++)
            {
                var equipPartPlus = info.InfoList[i];
                EquipStrength equipStrength = new EquipStrength();
                equipStrength.Type = equipPartPlus.PackType;
                equipStrength.EquipIndex = equipPartPlus.EquipIndex;
                equipStrength.StrengthLevel = equipPartPlus.EquipPartStarLV;
                equipStrength.Exp = (int)equipPartPlus.Proficiency;
                equipStrength.EvolveLV = equipPartPlus.EvolveLV;
                if (EquipStrengthDic.ContainsKey(equipPartPlus.EquipIndex))
                {
                    var equip = EquipStrengthDic[equipPartPlus.EquipIndex];
                    EquipStrengthDic[equipPartPlus.EquipIndex] = equipStrength;
                    if (equip.StrengthLevel != equipPartPlus.EquipPartStarLV && EquipStrengthLvUpdate != null)
                    {
                        EquipStrengthLvUpdate(equipPartPlus.EquipPartStarLV);
                    }
                    if (equip.EvolveLV != equipPartPlus.EvolveLV && EquipStrngthEvolutionLv != null)
                    {
                        EquipStrngthEvolutionLv();
                    }
                }
                else
                {
                    EquipStrengthDic.Add(equipPartPlus.EquipIndex, equipStrength);
                }
            }
            if (EquipStrengthUpdate != null)
            {
                EquipStrengthUpdate();
            }
 
            if (isServerPrepare)
            {
                UpdateRedpoint();
            }
        }
 
        public void SendEquip(int equipIndex, int packTyp = 1)
        {
            CA301_tagEquipPlus CA301 = new CA301_tagEquipPlus();
            CA301.PackType = (byte)packTyp;
            CA301.ItemIndex = (ushort)equipIndex;
            GameNetSystem.Instance.SendInfo(CA301);
        }
 
        public void SendEquipPlusEvolve(int equipIndex)
        {
            CA316_tagCMEquipPlusEvolve CA316 = new CA316_tagCMEquipPlusEvolve();
            CA316.ItemIndex = (ushort)equipIndex;
            GameNetSystem.Instance.SendInfo(CA316);
        }
        private void InitEquipLevelMax()
        {
            //强化等级上限受装备阶影响
            var itemPlusMax = ItemPlusMaxConfig.GetValues();
            foreach (var value in itemPlusMax)
            {
                Dictionary<int, int> LevelDict = null;
                if (!EquipLevelMaxDic.TryGetValue(value.EquipType, out LevelDict))
                {
                    LevelDict = new Dictionary<int, int>();
                    EquipLevelMaxDic.Add(value.EquipType, LevelDict);
                }
                LevelDict.Add(value.equipLevel, value.levelMax);
            }
        }
 
        public static int GetEquipStrengthType(int equipPlace)//获取装备类型
        {
            int type = 1;
            if (PartTypeDic.ContainsKey(equipPlace))
            {
                type = PartTypeDic[equipPlace];
            }
            return type;
        }
 
        public int GetEquipLevelMax(int type, int equipLV)//获取某一类型的最大强化等级
        {
            int lv = 0;
            if (EquipLevelMaxDic.ContainsKey(type))
            {
                var LevelDict = EquipLevelMaxDic[type];
                if (LevelDict.ContainsKey(equipLV))
                {
                    return LevelDict[equipLV];
                }
            }
            return lv;
        }
 
        public List<EquipTypeClass> GetEquipValueList(int level, int equipPlace, int addlv = 0)//当前获得的强化属性
        {
            List<EquipTypeClass> EquipTypeList = new List<EquipTypeClass>();
            int type = GetEquipStrengthType(equipPlace);
            int equiplv = 0;
            int equipIndex = EquipPlaceMapConfig.GetServerPlace(level, equipPlace);
            if (EquipStrengthDic.ContainsKey(equipIndex))
            {
                equiplv = EquipStrengthDic[equipIndex].StrengthLevel;
            }
            equiplv += addlv;
            var itemPlus = ItemPlusConfig.GetTypeAndLevel(type, equiplv);
            if (itemPlus != null)
            {
                int[] attType = itemPlus.attType;
                int[] attValue = itemPlus.attValue;
                for (int i = 0; i < attType.Length; i++)
                {
                    EquipTypeClass equipType = new EquipTypeClass();
                    equipType.AttType = attType[i];
                    equipType.AttValue = attValue[i];
                    var config = PlayerPropertyConfig.Get(attType[i]);
                    if (config != null)
                    {
                        equipType.StrName = config.Name;
                    }
                    EquipTypeList.Add(equipType);
                }
            }
            return EquipTypeList;
 
        }
        public ItemPlusConfig GetEquipConfig(int level, int equipPlace)
        {
            ItemPlusConfig itemPlusConfig = new ItemPlusConfig();
            int type = GetEquipStrengthType(equipPlace);
            int equiplv = 0;
            int equipIndex = EquipPlaceMapConfig.GetServerPlace(level, equipPlace);
            if (EquipStrengthDic.ContainsKey(equipIndex))
            {
                equiplv = EquipStrengthDic[equipIndex].StrengthLevel;
            }
            itemPlusConfig = ItemPlusConfig.GetTypeAndLevel(type, equiplv);
            return itemPlusConfig;
        }
 
        public EquipPlusEvolveClass GetEquipPlusEvolve(int equipPlace, int equipLv)//获取装备进化数据
        {
            EquipPlusEvolveClass equipPlusEvolve = new EquipPlusEvolveClass();
            int lvType = 1;
            if (equipLv != 0)
            {
                lvType = equipLv;
            }
            var equipPlusEvolveConfig = EquipPlusEvolveConfig.GetEquipPlaceAndEvolveLV(equipPlace, lvType);
            if (equipPlusEvolveConfig != null)
            {
                equipPlusEvolve.EquipType = equipPlusEvolveConfig.EquipPlace;
                equipPlusEvolve.EvolveLV = equipPlusEvolveConfig.EvolveLV;
                equipPlusEvolve.NeedPlusLV = equipPlusEvolveConfig.NeedPlusLV;
                var Dic1 = ConfigParse.GetDic<int, int>(equipPlusEvolveConfig.CostItem);
                foreach (var key in Dic1.Keys)
                {
                    equipPlusEvolve.CostItemID = key;
                    equipPlusEvolve.CostItemCount = Dic1[key];
                }
                var Dic2 = ConfigParse.GetDic<int, float>(equipPlusEvolveConfig.Attr);
                foreach (var key in Dic2.Keys)
                {
                    equipPlusEvolve.AttrType = key;
                    var config = PlayerPropertyConfig.Get(key);
                    if (config != null)
                    {
                        equipPlusEvolve.AttrName = config.Name;
                        float value = Dic2[key];
                        switch (config.ISPercentage)
                        {
                            case 0:
                                equipPlusEvolve.AttrValue = value.ToString();
                                if (equipLv == 0)
                                {
                                    equipPlusEvolve.AttrValue = 0.ToString();
                                }
                                break;
                            case 1:
                                equipPlusEvolve.AttrValue = (value / 100).ToString() + "%";
                                if (equipLv == 0)
                                {
                                    equipPlusEvolve.AttrValue = 0.ToString() + "%";
                                }
                                break;
                            case 2:
                                equipPlusEvolve.AttrValue = value.ToString() + "%";
                                if (equipLv == 0)
                                {
                                    equipPlusEvolve.AttrValue = 0.ToString() + "%";
                                }
                                break;
                        }
                    }
                }
            }
            return equipPlusEvolve;
        }
 
        private void GetEvolutionTypeMax()
        {
            var evolveValues = EquipPlusEvolveConfig.GetValues();
            foreach (var value in evolveValues)
            {
                if (EvolutionTypeMaxDic.ContainsKey(value.EquipPlace))
                {
                    var lv = EvolutionTypeMaxDic[value.EquipPlace];
                    if (value.EvolveLV > lv)
                    {
                        EvolutionTypeMaxDic[value.EquipPlace] = value.EvolveLV;
                    }
                }
                else
                {
                    EvolutionTypeMaxDic.Add(value.EquipPlace, value.EvolveLV);
                }
            }
        }
 
        public EquipStrength GetEquipStrength(int level, int equipPlace)
        {
            EquipStrength equipStrength = new EquipStrength();
            int equipIndex = EquipPlaceMapConfig.GetServerPlace(level, equipPlace);
            if (EquipStrengthDic.ContainsKey(equipIndex))
            {
                equipStrength = EquipStrengthDic[equipIndex];
            }
            return equipStrength;
        }
 
        public int GetStrengthLevel(int level, int equipPlace)
        {
            int lv = 0;
            int equipIndex = EquipPlaceMapConfig.GetServerPlace(level, equipPlace);
            if (EquipStrengthDic.ContainsKey(equipIndex))
            {
                lv = EquipStrengthDic[equipIndex].StrengthLevel;
            }
 
            return lv;
        }
 
        public int GetStrengthLevelByColor(int level, int equipPlace)
        {
            int lv = 0;
            var guid = equipModel.GetEquip(new Int2(level, equipPlace));
            if (guid == string.Empty) return lv;
            var item = packModel.GetItemByGuid(guid);
 
            int equipIndex = EquipPlaceMapConfig.GetServerPlace(level, equipPlace);
            if (EquipStrengthDic.ContainsKey(equipIndex))
            {
                lv = EquipStrengthDic[equipIndex].StrengthLevel;
            }
                
            return lv;
        }
 
 
        public int GetMasterLV(int level)
        {
            int masterLV = 0;
            PlusMasterDict.TryGetValue(level, out masterLV);
            return masterLV;
        }
 
 
        public int GetStrengthEvolveLevel(int level, int equipPlace)
        {
            int lv = 0;
            int equipIndex = EquipPlaceMapConfig.GetServerPlace(level, equipPlace);
            if (EquipStrengthDic.ContainsKey(equipIndex))
            {
                lv = EquipStrengthDic[equipIndex].EvolveLV;
            }
            return lv;
        }
 
        // 依据装备品质(颜色)获取8件套最低等级
        public int GetStrengthMinLV(int level)
        {
            int lv;
            int minLV = -1;
            int equipIndex = 0;
            for (int i = 1; i <= 8; i++)
            {
                var guid = equipModel.GetEquip(new Int2(level, i));
                if (guid != string.Empty)
                {
 
                    equipIndex = EquipPlaceMapConfig.GetServerPlace(level, i);
                    if (EquipStrengthDic.ContainsKey(equipIndex))
                    {
                        lv = EquipStrengthDic[equipIndex].StrengthLevel;
                    }
                    else
                    {
                        lv = 0;
                    }
 
                }
                else
                {
                    lv = 0;
                }
 
                if (minLV == -1)
                    minLV = lv;
                minLV = Math.Min(minLV, lv);
            }
 
            return Math.Max(minLV, 0);
        }
 
        public int GetCountActiveMaster(int level, int color, int masterLV)
        {
            int count = 0;
            for (int i = 1; i <= 8; i++)
            {
                var guid = equipModel.GetEquip(new Int2(level, i));
                if (guid != string.Empty)
                {
                    var item = packModel.GetItemByGuid(guid);
                    if (ItemLogicUtility.Instance.GetItemQuality(item.itemId, null) >= color)
                    {
                        int equipIndex = EquipPlaceMapConfig.GetServerPlace(level, i);
                        if (EquipStrengthDic.ContainsKey(equipIndex) && EquipStrengthDic[equipIndex].StrengthLevel >= masterLV)
                        {
                            count++;
                        }
 
                    }
                }
 
            }
 
            return count;
        }
 
 
        public int GetEquipStrengthState(Int2 position)
        {
            var equipGuid = equipModel.GetEquip(position);
            if (string.IsNullOrEmpty(equipGuid))
            {
                return 3;
            }
 
            var serverPlace = EquipPlaceMapConfig.GetServerPlace(position.x, position.y);
 
            var item = packModel.GetItemByGuid(equipGuid);
 
 
            int equipLevel = 0;
            int advancedLevel = 0;
 
            if (EquipStrengthDic.ContainsKey(serverPlace))//获取当前强化等级
            {
                equipLevel = EquipStrengthDic[serverPlace].StrengthLevel;
                advancedLevel = EquipStrengthDic[serverPlace].EvolveLV;
            }
 
            int equipType = EquipStrengthModel.GetEquipStrengthType(position.y);
 
            int maxLevel = GetEquipLevelMax(equipType, position.x);//获取最大强化等级
            if (equipLevel >= maxLevel)//满级
            {
                return 2;
            }
            // 强化进阶限制强化
            var equipPlusEvolveConfig = EquipPlusEvolveConfig.GetEquipPlaceAndEvolveLV(position.y, advancedLevel+1);
            if (equipPlusEvolveConfig != null)
            {
                if (equipLevel >= equipPlusEvolveConfig.NeedPlusLV)//强化上限
                {
                    return 1;
                }
            }
            return 0;
        }
 
        public bool SatisfyEquipAdvance(Int2 position)
        {
            int equipLv = 0;
            int advancedLv = 0;
            int itemCount = 0;
            int equipIndex = EquipPlaceMapConfig.GetServerPlace(position.x, position.y);
            if (EquipStrengthDic.ContainsKey(equipIndex))//获取当前强化等级
            {
                equipLv = EquipStrengthDic[equipIndex].StrengthLevel;
                advancedLv = EquipStrengthDic[equipIndex].EvolveLV;
            }
            var equipPlusEvolve = GetEquipPlusEvolve(position.y, advancedLv + 1);
            if (equipPlusEvolve == null)
            {
                return false;
            }
            if (equipPlusEvolve.NeedPlusLV > equipLv)
            {
                return false;
            }
            itemCount = packModel.GetItemCountByID(PackType.Item, equipPlusEvolve.CostItemID);
            if (equipPlusEvolve.CostItemCount > itemCount)
            {
                return false;
            }
            //满级最后一档不进化
            if (GetEquipStrengthState(position) == 2) return false;
            return true;
        }
 
        public bool HasEnoughMoney(Int2 position)
        {
            var config = GetEquipConfig(position.x, position.y);
            if (config == null)
            {
                return false;
            }
 
            bool result = true;
            ulong money = UIHelper.GetMoneyCnt(3);
            ulong requireMoney = (ulong)config.costCount;
            if (money < requireMoney)
                result = false;
 
            if (config.costItemInfo.Length == 2)
            {
                var itemCount = packModel.GetItemCountByID(PackType.Item, config.costItemInfo[0]);
                if (itemCount < config.costItemInfo[1])
                {
                    result = false;
                }
            }
 
            return result;
        }
 
        public bool TryGetRedpoint(int level, out Redpoint _redpoint)
        {
            return m_EquipSetRedpoints.TryGetValue(level, out _redpoint);
        }
 
        public bool TryGetRedpoint(int level, int place, out EquipStrengthRedpoint _redpoint)
        {
            var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
            return m_EquipStrengthRedpoints.TryGetValue(packIndex, out _redpoint);
        }
 
        public void SetDayRemind()
        {
            if (redpoint.state == RedPointState.Simple)
            {
                DayRemind.Instance.SetDayRemind(DayRemind.EQUIPSTRENGTH_REDPOINT, true);
                UpdateRedpoint();
            }
        }
 
        public bool ExistAnySatisfyStrengh()
        {
            var equipSets = equipModel.GetUnLockedEquipSets();
            foreach (var level in equipSets)
            {
                foreach (var place in equipPlaces)
                {
                    var position = new Int2(level, place);
                    var equipGuid = equipModel.GetEquip(position);
                    if (string.IsNullOrEmpty(equipGuid))
                    {
                        continue;
                    }
 
                    var state = GetEquipStrengthState(position);
                    if (state != 0)
                    {
                        continue;
                    }
 
                    if (!HasEnoughMoney(position))
                    {
                        continue;
                    }
 
                    return true;
                }
            }
            return false;
        }
 
        public void UpdateRedpoint()
        {
            if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Strength))
            {
                RefreshRedpoint(Int2.zero, 0);
                return;
            }
 
            RefreshMasterRedpoint();
 
            var equipSets = equipModel.GetAllEquipSets();
            foreach (var level in equipSets)
            {
                foreach (var place in equipPlaces)
                {
                    var position = new Int2(level, place);
                    var equipGuid = equipModel.GetEquip(position);
                    if (string.IsNullOrEmpty(equipGuid))
                    {
                        continue;
                    }
                    if (SatisfyEquipAdvance(position))
                    {
                        RefreshRedpoint(position, 2);
                        return;
                    }
                }
            }
 
            //Int3 limit = redpointLimits[0];
            //var isLast = false;
            //for (int i = redpointLimits.Length - 1; i >= 0; i--)
            //{
            //    if (PlayerDatas.Instance.baseData.LV >= redpointLimits[i].x)
            //    {
            //        limit = redpointLimits[i];
            //        if (i == redpointLimits.Length - 1)
            //        {
            //            isLast = true;
            //        }
            //        break;
            //    }
            //}
 
            //if (isLast)
            //{
            //    if (DayRemind.Instance.GetDayRemind(DayRemind.EQUIPSTRENGTH_REDPOINT))
            //    {
            //        RefreshRedpoint(Int2.zero, 0);
            //        return;
            //    }
            //}
 
            //var money = UIHelper.GetMoneyCnt(3);
            //if (money < (ulong)limit.y)
            //{
            //    RefreshRedpoint(Int2.zero, 0);
            //    return;
            //}
 
            var satisfyPosition = Int2.zero;
            var minStage = int.MaxValue;
            foreach (var level in equipSets)
            {
                foreach (var place in equipPlaces)
                {
                    var position = new Int2(level, place);
                    var equipGuid = equipModel.GetEquip(position);
                    if (string.IsNullOrEmpty(equipGuid))
                    {
                        continue;
                    }
 
                    var state = GetEquipStrengthState(position);
                    if (state != 0)
                    {
                        continue;
                    }
 
                    if (!HasEnoughMoney(position))
                    {
                        continue;
                    }
 
                    var serverPlace = EquipPlaceMapConfig.GetServerPlace(position.x, position.y);
                    var strengthLevel = 0;
                    if (EquipStrengthDic.ContainsKey(serverPlace))
                    {
                        strengthLevel = EquipStrengthDic[serverPlace].StrengthLevel;
                    }
                    var stage = strengthLevel / 10;// limit.z;
 
                    if (minStage > stage)
                    {
                        minStage = stage;
                        satisfyPosition = position;
                    }
                }
            }
 
            RefreshRedpoint(satisfyPosition, 1);
        }
 
        void RefreshRedpoint(Int2 position, int type)
        {
            var equipSets = equipModel.GetAllEquipSets();
            foreach (var level in equipSets)
            {
                foreach (var place in equipPlaces)
                {
                    var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
                    EquipStrengthRedpoint redpoint;
                    TryGetRedpoint(level, place, out redpoint);
 
                    redpoint.strengthRedpoint.state =
                        position.x == level && position.y == place && type == 1 ? RedPointState.Simple : RedPointState.None;
                    redpoint.advanceRedpoint.state =
                        position.x == level && position.y == place && type == 2 ? RedPointState.Simple : RedPointState.None;
                    if (level == 1 && place > 8)
                    {
                        redpoint.strengthRedpoint.state = RedPointState.None;
                        redpoint.advanceRedpoint.state = RedPointState.None;
                    }
                }
            }
        }
 
 
        public void RefreshMasterRedpoint()
        {
            foreach (var level in equipModel.GetUnLockedEquipSets())
            {
                //判断每套是否点亮
                var curMasterLV = GetMasterLV(level);
                var masterInfo = ItemPlusMasterConfig.TryGetNextMaster(level, curMasterLV);
 
                if (masterInfo != null && (GetStrengthMinLV(level) >= masterInfo.MasterPlusLV))
                {
                    m_EquipSetMasterRedpoints[level].state = RedPointState.Simple;
                }
                else
                {
                    m_EquipSetMasterRedpoints[level].state = RedPointState.None;
                }
            }
        }
 
        public void ActiveMasterPack(HA3C2_tagMCMasterPlusLVInfo pack)
        {
            for (int i = 0; i < pack.Count; i++)
            {
                PlusMasterDict[pack.MasterPlusLVInfoList[i].ClassLV] = pack.MasterPlusLVInfoList[i].MasterPlusLV;
            }
            if (StrengthMasterFresh != null)
                StrengthMasterFresh();
 
            UpdateRedpoint();
        }
 
        public class EquipStrengthRedpoint
        {
            public readonly Redpoint redpoint;
            public readonly Redpoint strengthRedpoint;
            public readonly Redpoint advanceRedpoint;
 
            public EquipStrengthRedpoint(int baseId)
            {
                redpoint = new Redpoint(baseId, EquipStrengthModel.REDPOINTBASE++);
                strengthRedpoint = new Redpoint(redpoint.id, EquipStrengthModel.REDPOINTBASE++);
                advanceRedpoint = new Redpoint(redpoint.id, EquipStrengthModel.REDPOINTBASE++);
            }
        }
    }
 
 
 
}