少年修仙传客户端代码仓库
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
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
 
using UnityEngine;
namespace vnxbqy.UI
{
    
    public class DogzModel : Model,IBeforePlayerDataInitialize,IAfterPlayerDataInitialize,IPlayerLoginOk
    {
        Dictionary<int, string> m_StarLevelLabels;
 
        PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        GodBeastModel beastModel { get { return ModelCenter.Instance.GetModel<GodBeastModel>(); } }
 
        public override void Init()
        {
            ParseConfig();
            SetDogzAndEquipPlaceRedKey();
            playerPack.refrechPackEvent += UpdateDogzEquipInfo;
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            playerPack.refreshItemCountEvent -= RefreshDogzEquipInfo;
            FuncOpen.Instance.OnFuncStateChangeEvent -= UpdateDogzState;
            curSumAssistNum = DogzAssistDefaultCnt;
            addAssistCnt = 0;
            SelectDogzItemQuality = 0;
            SelectDogzItemStart = 0;
            dogzItemList = new List<ItemModel>();
            selectEquipPlacelist = new List<ItemModel>();
            dogzAssistStateDict = new Dictionary<int, int>();
            m_DogzEquipAttrDict = new Dictionary<int, int>();
            m_DogzAttrDict = new Dictionary<int, int>();
        }
 
        public void OnAfterPlayerDataInitialize()
        {
           
        }
 
        public void OnPlayerLoginOk()
        {
            playerPack.refreshItemCountEvent += RefreshDogzEquipInfo;
            FuncOpen.Instance.OnFuncStateChangeEvent += UpdateDogzState;
            UpdateDogzAssistRed();
            UpdateDogzEquipPlaceRed();
            UpdateAssistNumRed();
        }
 
        public override void UnInit()
        {
            playerPack.refrechPackEvent -= UpdateDogzEquipInfo;
        }
 
        #region 配置
        private Dictionary<int, Dictionary<int, int>> m_DogzEquipLimit = new Dictionary<int, Dictionary<int, int>>(); //装备位 品质限制
        public int DogzAssistDefaultCnt { get; private set; }  //助战神兽默认数量
        public int DogzAssistMaxCnt { get; private set; }//助战神兽最大数
        public int AddAssistItem { get; private set; } //增加助战神兽总数的物品Id
        public int DogzPackGridCnt { get; private set; } //神兽物品背包格子数
        public int[] AddAssistItemCnt { get; private set; } //增加助战神兽总数的物品数量
        public Dictionary<int, int> m_DogzEquipStrenLimit { get; private set;} //神兽装备强化上限 品质 强化等级
        public string dogzScoreFormula { get; private set; } //神兽评分公式
        void ParseConfig()
        {
            var _dogzCfgs = DogzConfig.GetValues();
            for (int i = 0; i < _dogzCfgs.Count; i++)
            {
                var _dict = new Dictionary<int, int>();
                for(int j = 0; j < _dogzCfgs[i].EquipPlaceColorList.Length; j++)
                {
                    _dict.Add(j, _dogzCfgs[i].EquipPlaceColorList[j]);
                }
                m_DogzEquipLimit.Add(_dogzCfgs[i].ID, _dict);
            }
            var _funcCfg = FuncConfigConfig.Get("DogzAssist");
            int[] assistDogz = ConfigParse.GetMultipleStr<int>(_funcCfg.Numerical1);
            DogzAssistDefaultCnt = assistDogz[0];
            DogzAssistMaxCnt = assistDogz[1];
            AddAssistItem = int.Parse(_funcCfg.Numerical2);
            AddAssistItemCnt = ConfigParse.GetMultipleStr<int>(_funcCfg.Numerical3);
            m_DogzEquipStrenLimit = ConfigParse.GetDic<int, int>(_funcCfg.Numerical4);
            _funcCfg = FuncConfigConfig.Get("DogzPack");
            DogzPackGridCnt = int.Parse(_funcCfg.Numerical1);
            _funcCfg = FuncConfigConfig.Get("DogzGrade");
            dogzScoreFormula = _funcCfg.Numerical1;
            m_StarLevelLabels = ConfigParse.GetDic<int, string>(_funcCfg.Numerical2);
        }
        /// <summary>
        /// 获得格子可以穿戴的装备限制  神兽Id  格子索引 
        /// </summary>
        /// <param name="_dogzId"></param>
        /// <param name="_index"></param>
        /// <returns></returns>
        public int GetDogzEquipLimitByIndex(int _dogzId, int _index)
        {
            if (m_DogzEquipLimit.ContainsKey(_dogzId))
            {
                var _dict = m_DogzEquipLimit[_dogzId];
                if (_dict.ContainsKey(_index))
                {
                    return _dict[_index];
                }
            }
            return 0;
        }
 
        /// <summary>
        /// 得到神兽格子对应的装备部位
        /// </summary>
        /// <param name="_index"></param>
        /// <returns></returns>
        public string GetDogzPartNameByIndex(int _index)
        {
            switch (_index)
            {
                case 0:
                    return Language.Get("DogzEquip1");
                case 1:
                    return Language.Get("DogzEquip2");
                case 2:
                    return Language.Get("DogzEquip3");
                case 3:
                    return Language.Get("DogzEquip4");
                case 4:
                    return Language.Get("DogzEquip5");
                default:
                    return string.Empty;
            }
        }
 
        public string GetItemColorName(int _itemColor)
        {
            switch (_itemColor)
            {
                case 0:
                case 1:
                    return Language.Get("DogzWhite");
                case 2:
                    return Language.Get("DogzBlue");
                case 3:
                    return Language.Get("DogzPurple");
                case 4:
                    return Language.Get("DogzOrange");
                case 5:
                    return Language.Get("DogzRed");
                case 6:
                    return Language.Get("DogzPink");
                default:
                    return string.Empty;
            }
        }
 
        public int GetDogzScoreById(int dogzId)
        {
            DogzConfig dogzConfig = DogzConfig.Get(dogzId);
            if (dogzConfig == null) return 0;
            Equation.Instance.Clear();
            Equation.Instance.AddKeyValue("FightPowerEx",dogzConfig.FightPowerEx);
            Equation.Instance.AddKeyValue("EquipGSFormula", GetDogzEquipScore(dogzId));
            GetDogzAttrDictById(dogzId);
            foreach(var key in m_DogzAttrDict.Keys)
            {
                PlayerPropertyConfig propertyConfig = PlayerPropertyConfig.Get(key);
                if (propertyConfig != null)
                {
                    Equation.Instance.AddKeyValue(propertyConfig.Parameter, m_DogzAttrDict[key]);
                }
            }
            return Equation.Instance.Eval<int>(dogzScoreFormula);
        }
        public Dictionary<int, int> m_DogzAttrDict { get; private set; }
        public Dictionary<int, int> GetDogzAttrDictById(int dogzId)
        {
            m_DogzAttrDict.Clear();
            DogzConfig dogzConfig = DogzConfig.Get(dogzId);
            int[] baseAttrIds = dogzConfig.BaseAttrTypes;
            int[] baseAttrValues = dogzConfig.BaseAttrValues;
            for (int i = 0; i < baseAttrIds.Length; i++)
            {
                if (!m_DogzAttrDict.ContainsKey(baseAttrIds[i]))
                {
                    m_DogzAttrDict.Add(baseAttrIds[i], baseAttrValues[i]);
                }
                else
                {
                    m_DogzAttrDict[baseAttrIds[i]] += baseAttrValues[i];
                }
            }
 
            Dictionary<int, int> dogzStrenDict = beastModel.AllEnhancedProperties(dogzId);
            foreach (var key in dogzStrenDict.Keys)
            {
                if (!m_DogzAttrDict.ContainsKey(key))
                {
                    m_DogzAttrDict.Add(key, dogzStrenDict[key]);
                }
                else
                {
                    m_DogzAttrDict[key] += dogzStrenDict[key];
                }
            }
            return m_DogzAttrDict;
        }
 
        public int GetDogzEquipScore(int dogzId)
        {
            int score = 0;
            List<ItemModel> itemModels = GetDogzEquips(dogzId);
            if(itemModels != null)
            {
                for(int i = 0; i < itemModels.Count; i++)
                {
                    score += itemModels[i].score;
                }
            }
            return score;
        }
 
        #endregion
 
        private void UpdateDogzEquipInfo(PackType type)
        {
            if (type != PackType.DogzEquip) return;
 
            SetDogzEquipInfo();
        }
 
        public int GetAssistItemCnt()
        {
            if(!IsAddMaxAssist())
            {
                return AddAssistItemCnt[addAssistCnt];
            }
            else
            {
 
                return AddAssistItemCnt[AddAssistItemCnt.Length - 1];
            }
        }
 
        public void MakeUseAddAssistNum()
        {
            if (IsAddMaxAssist())
            {
                SysNotifyMgr.Instance.ShowTip("DogzNumLimit");
                return;
            }
 
            var _itemConfig = ItemConfig.Get(AddAssistItem);
            ConfirmCancel.ShowItemConfirm(Language.Get("DogzFunc102", _itemConfig.ItemName,GetAssistItemCnt()),
             AddAssistItem, GetAssistItemCnt(), () =>
             {
                 SendBuyAssistCnt();
             });
        }
 
        public bool IsAddMaxAssist()
        {
            if (curSumAssistNum < DogzAssistMaxCnt)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
 
        public int presentSelectDogz { get; set; } //当前选中的神兽id
        public event Action UpdateSelectDogzEvent;
        public void SetSelectDogz(int _id)
        {
            presentSelectDogz = _id;
            if (UpdateSelectDogzEvent != null)
            {
                UpdateSelectDogzEvent();
            }
        }
 
        public event Action<int,int> OpenFuncEvent;
        public void OpenDogzFuncEvent(int functionOrder,int equipIndex)
        {
            if(OpenFuncEvent != null)
            {
                OpenFuncEvent(functionOrder,equipIndex);
            }
        }
 
        public bool CheckIsAddAssistNum()
        {
            if(GetAssistItemCnt() <= playerPack.GetItemCountByID(PackType.DogzItem, AddAssistItem))
            {
                return true;
            }
            return false;
        }
 
        public bool CheckIsPutOn(int id)
        {
            ItemConfig config = ItemConfig.Get(id);
            if (config == null) return false;
 
            int index = config.EquipPlace % 100 - 1;
            int color = GetDogzEquipLimitByIndex(presentSelectDogz, index);
            if (config.ItemColor >= color)
            {
                return true;
            }
            SysNotifyMgr.Instance.ShowTip("DogzQualityAsk", GetDogzPartNameByIndex(index), GetItemColorName(color));
            return false;
        }
 
 
        private void UpdateDogzState(int funcId)
        {
            if (funcId != (int)FuncOpenEnum.Dogz) return;
 
            UpdateDogzAssistRed();
            UpdateDogzEquipPlaceRed();
            UpdateAssistNumRed();
        }
 
 
        #region 协议
 
        public int addAssistCnt { get; private set; } //额外购买的助战数
        public int curSumAssistNum { get; private set; } //当前可以助战的神兽数量
        public void SetServerAddAssistDogzCnt(HA3C0_tagMCDogzInfo info)
        {
            addAssistCnt = info.BuyHelpbattleCount;
            curSumAssistNum = DogzAssistDefaultCnt + addAssistCnt;
            if (UpdateAssistDogzEvent != null)
            {
                UpdateAssistDogzEvent();
            }
            UpdateDogzAssistRed();
            UpdateDogzEquipPlaceRed();
            UpdateAssistNumRed();
        }
 
        public event Action UpdateAssistDogzEvent;
        public Dictionary<int, int> dogzAssistStateDict { get; private set; } //神兽助战
        public void SetServerAssistDogzState(HA3C1_tagMCDogzHelpbattleState info)
        {
            if(!dogzAssistStateDict.ContainsKey(info.DogzID))
            {
                dogzAssistStateDict.Add(info.DogzID,info.BatteState);
            }
            else
            {
                dogzAssistStateDict[info.DogzID] = info.BatteState;
            }
 
            if (UpdateAssistDogzEvent != null)
            {
                UpdateAssistDogzEvent();
            }
 
            UpdateDogzAssistRed();
            UpdateDogzEquipPlaceRed();
        }
 
        public int GetAssistDogzCount()
        {
            int assistCnt = 0;
            foreach(var key in dogzAssistStateDict.Keys)
            {
                if(dogzAssistStateDict[key] == 1)
                {
                    assistCnt += 1;
                }
            }
            return assistCnt;
        }
 
        public bool TryGetAssistDogzState(int dogzId)
        {
            int state = 0;
            dogzAssistStateDict.TryGetValue(dogzId,out state);
            return state == 0 ? false : true;
        }
 
        public int GetMinAssistDogzId()
        {
            int minAssistId = 0;
            foreach (var dogzId in dogzAssistStateDict.Keys)
            {
                if (TryGetAssistDogzState(dogzId)
                    && ((minAssistId > dogzId && minAssistId != 0) || minAssistId == 0))
                {
                    minAssistId = dogzId;
                }
            }
            return minAssistId;
        }
 
        public void SetDogzEquipInfo()
        {
            m_DogzEquipDict.Clear();
            SinglePack singlePack = playerPack.GetSinglePack(PackType.DogzEquip);
            if (singlePack == null) return;
 
            Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
            foreach(var index in pairs.Keys)
            {
                ItemModel itemModel = pairs[index];
                int dogzId = GetDogzIDByIndex(index);
                if (!m_DogzEquipDict.ContainsKey(dogzId))
                {
                    List<ItemModel> equipDatas = new List<ItemModel>();
                    equipDatas.Add(itemModel);
                    m_DogzEquipDict.Add(dogzId, equipDatas);
                }
                else
                {
                    m_DogzEquipDict[dogzId].Add(itemModel);
                }
                
            }
        }
 
        public Action<int> RefreshDogzEquipAct;
        private void RefreshDogzEquipInfo(PackType type, int index, int id)
        {
            if(type == PackType.DogzItem && id == AddAssistItem)
            {
                UpdateAssistNumRed();
            }
            else if(type == PackType.DogzItem)
            {
                UpdateDogzAssistRed();
                UpdateDogzEquipPlaceRed();
            }
            else if(type == PackType.DogzEquip)
            {
                ItemModel itemModel = playerPack.GetItemByIndex(type, index);
                int dogzId = GetDogzIDByIndex(index);
                List<ItemModel> modellist = GetDogzEquips(dogzId);
                if (modellist != null)
                {
                    if (itemModel != null)
                    {
                        bool isAdd = true;
                        for (int i = 0; i < modellist.Count; i++)
                        {
                            if (modellist[i].gridIndex == index)
                            {
                                isAdd = false;
                                modellist[i] = itemModel;
                                break;
                            }
                        }
                        if (isAdd)
                        {
                            modellist.Add(itemModel);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < modellist.Count; i++)
                        {
                            if (modellist[i].gridIndex == index)
                            {
                                modellist.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    if (itemModel != null)
                    {
                        List<ItemModel> equipDatas = new List<ItemModel>();
                        equipDatas.Add(itemModel);
                        m_DogzEquipDict.Add(dogzId, equipDatas);
                    }
                }
 
                if (RefreshDogzEquipAct != null)
                {
                    RefreshDogzEquipAct(dogzId);
                }
 
                UpdateDogzAssistRed();
                UpdateDogzEquipPlaceRed();
            }
        }
 
        /// <summary>
        /// 获得神兽穿戴的装备数据
        /// </summary>
        private Dictionary<int, List<ItemModel>> m_DogzEquipDict = new Dictionary<int, List<ItemModel>>();
 
        public List<ItemModel> GetDogzEquips(int _dogzId)
        {
            List<ItemModel> _list = null;
            m_DogzEquipDict.TryGetValue(_dogzId,out _list);
            return _list;
        }
 
        /// <summary>
        /// 获得助战属性加成
        /// </summary>
        public Dictionary<int,int> m_DogzEquipAttrDict { get; private set; }
        public Dictionary<int,int> GetDogzEquipAddAttr(int dogzId)
        {
            m_DogzEquipAttrDict.Clear();
            DogzConfig dogzConfig = DogzConfig.Get(dogzId);
            int[] baseAttrIds = dogzConfig.BaseAttrTypes;
            Dictionary<int, int> dogzStrenDict = beastModel.AllEnhancedProperties(dogzId);
            for (int i = 0; i < baseAttrIds.Length; i++)
            {
                int attrValue = 0;
                List<ItemModel> itemModels = GetDogzEquips(dogzId);
                if(itemModels != null)
                {
                    for(int j = 0; j < itemModels.Count; j++)
                    {
                        ItemConfig itemConfig = ItemConfig.Get(itemModels[j].itemId);
 
                        if(itemConfig.Effect1 == baseAttrIds[i])
                        {
                            attrValue += itemConfig.EffectValueA1;
                        }
                        if (itemConfig.Effect2 == baseAttrIds[i])
                        {
                            attrValue += itemConfig.EffectValueA2;
                        }
                        if (itemConfig.Effect3 == baseAttrIds[i])
                        {
                            attrValue += itemConfig.EffectValueA3;
                        }
                        if (itemConfig.Effect4 == baseAttrIds[i])
                        {
                            attrValue += itemConfig.EffectValueA4;
                        }
                        if (itemConfig.Effect5 == baseAttrIds[i])
                        {
                            attrValue += itemConfig.EffectValueA5;
                        }
                    }
                }
                if(dogzStrenDict.ContainsKey(baseAttrIds[i]))
                {
                    attrValue += dogzStrenDict[baseAttrIds[i]];
                }
                m_DogzEquipAttrDict.Add(baseAttrIds[i], attrValue);
            }
            return m_DogzEquipAttrDict;
        }
 
        public int GetDogzEquipPlaceByIndex(int index)
        {
            return (index % 5) + 101;
        }
 
        public int GetDogzIndexByPlace(int place)
        {
            return (place % 100) - 1;
        }
 
        public int GetDogzIDByIndex(int index)
        {
            return (index / 5) + 1;
        }
 
        /// <summary>
        /// 获得当前格子穿戴的装备
        /// </summary>
        /// <param name="_dogzId"></param>
        /// <param name="_index"></param>
        /// <param name="_equipData"></param>
        /// <returns></returns>
        public bool TryGetDogzEquip(int _dogzId, int _equipPlace, out ItemModel _equipData)
        {
            _equipData = null;
            List<ItemModel> _list = GetDogzEquips(_dogzId);
            if (_list == null)
            {
                return false;
            }
           
            for(int i = 0; i < _list.Count; i++)
            {
                int equipPlace = GetDogzEquipPlaceByIndex(_list[i].gridIndex);
                if(equipPlace == _equipPlace)
                {
                    _equipData = _list[i];
                    return true;
                }
            }
            return false;
        }
 
        public Dictionary<int,bool> dogzEquipStateDict { get; private set; }
        public Dictionary<int,bool> GetDogzEquipPlaceStates(int _dogzId)
        {
            dogzEquipStateDict = new Dictionary<int, bool>();
            for(int i = 0; i < 5; i++)
            {
                int equipPlace = GetDogzEquipPlaceByIndex(i);
                ItemModel _equipData = null;
                dogzEquipStateDict.Add(i, TryGetDogzEquip(_dogzId,equipPlace,out _equipData));
            }
            return dogzEquipStateDict;
        }
 
        public void CheckPutOff(int equipPlace)
        {
            if (TryGetAssistDogzState(presentSelectDogz))
            {
                ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),Language.Get("DogzFunc103"),
                    (bool isOk)=>
                    {
                        if(isOk)
                        {
                            SendPutOffEquip(equipPlace);
                        }
                        return;
                    });
            }
            else
            {
                SendPutOffEquip(equipPlace);
            }
        }
 
        public void SendPutOnEquip(List<int> indexlist)
        {
            if (indexlist == null || indexlist.Count < 1) return;
 
            GetDogzEquipPlaceStates(presentSelectDogz);
            CA5C0_tagCMDogzEquipItem dogzPutOn = new CA5C0_tagCMDogzEquipItem();
            dogzPutOn.DogzID = (byte)presentSelectDogz;
            dogzPutOn.EquipIndexCount = (byte)indexlist.Count;
            byte[] indexBytes = new Byte[indexlist.Count];
            for(int i = 0; i < indexBytes.Length; i++)
            {
                indexBytes[i] = (byte)indexlist[i];
            }
            dogzPutOn.EquipIndexList = indexBytes;
            GameNetSystem.Instance.SendInfo(dogzPutOn);
        }
 
        private void SendPutOffEquip(int equipPlace)
        {
            if(playerPack.GetEmptyGridCount(PackType.DogzItem) < 1)
            {
                SysNotifyMgr.Instance.ShowTip("DogzBagFull");
                return;
            }
            GetDogzEquipPlaceStates(presentSelectDogz);
            CA5C1_tagCMDogzUnEquipItem dogzPutOff = new CA5C1_tagCMDogzUnEquipItem();
            dogzPutOff.DogzID = (byte)presentSelectDogz;
            dogzPutOff.EquipPlace = (byte)equipPlace;
            GameNetSystem.Instance.SendInfo(dogzPutOff);
        }
 
        public void SendChangeDogzAssist(int assistState,int dogzId)
        {
            CA5C2_tagCMDogzBattleStateChange stateChange = new CA5C2_tagCMDogzBattleStateChange();
            stateChange.DogzID = (byte)dogzId;
            stateChange.BatteState = (byte)assistState;
            GameNetSystem.Instance.SendInfo(stateChange);
        }
 
        public void SendBuyAssistCnt()
        {
            CA5C3_tagCMDogzBuyBatteCount buyCnt = new CA5C3_tagCMDogzBuyBatteCount();
            GameNetSystem.Instance.SendInfo(buyCnt);
        }
 
        public void SendDogzEquipStrength(int index,List<int>indexlist,List<int> IndexUseCountList, int isDouble)
        {
            CA5C4_tagCMDogzEquipPlus dogzStren = new CA5C4_tagCMDogzEquipPlus();
            dogzStren.EquipIndex = (byte)index;
            dogzStren.IndexCount = (byte)indexlist.Count;
            byte[] indexByte = new byte[indexlist.Count];
            uint[] indexUseCountList = new uint[indexlist.Count];
            for (int i = 0; i < indexByte.Length; i++)
            {
                indexByte[i] = (byte)indexlist[i];
            }
            for (int i = 0; i < indexUseCountList.Length; i++)
            {
                indexUseCountList[i] = (uint)IndexUseCountList[i];
            }
            dogzStren.IndexUseCountList = indexUseCountList;
            dogzStren.IndexList = indexByte;
            dogzStren.IsDouble = (byte)isDouble;
            GameNetSystem.Instance.SendInfo(dogzStren);
        }
 
        #endregion
 
        public string GetStarLevelLabel(int starLevel)
        {
            if (m_StarLevelLabels != null && m_StarLevelLabels.ContainsKey(starLevel))
            {
                return m_StarLevelLabels[starLevel];
            }
            return string.Empty;
        }
 
        #region 神兽背包物品
        public int SelectDogzItemQuality { get; set; }
        public int SelectDogzItemStart { get; set; }
        public List<ItemModel> dogzItemList { get; private set; }
        public List<ItemModel> GetDogzItemList()
        {
            int[] dogzEquipTypes = new int[] { 119, 120, 121, 122, 123 };
            dogzItemList.Clear();
            SinglePack singlePack = playerPack.GetSinglePack(PackType.DogzItem);
            if (singlePack == null) return dogzItemList;
 
            Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
            foreach(var value in pairs.Values)
            {
                if (DogzBagSelectModel.Instance.GetSelectType() == 0)
                {
                    if (dogzEquipTypes.Contains(value.config.Type) && IsReachSelectCondi(value.itemId))
                    {
                        dogzItemList.Add(value);
                    }
                }
                else
                {
                    if (!dogzEquipTypes.Contains(value.config.Type))
                    {
                        dogzItemList.Add(value);
                    }
                }
            }
            dogzItemList.Sort(CompareByDogzItemPack);
            return dogzItemList;
        }
 
        public int GetDogzPackMatNum()
        {
            SinglePack singlePack = playerPack.GetSinglePack(PackType.DogzItem);
            if (singlePack == null) return 0;
 
            int num = 0;
            Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
            foreach (var value in pairs.Values)
            {
               if(value.config.EquipPlace == 0)
                {
                    num += 1;
                }
            }
            return num;
        }
 
        public bool IsReachSelectCondi(int itemId)
        {
            ItemConfig itemConfig = ItemConfig.Get(itemId);
            if (itemConfig == null ) return false;
 
            if (SelectDogzItemQuality == 0 && SelectDogzItemStart == 0) return true;
 
            if (SelectDogzItemQuality == 0 && itemConfig.StarLevel == SelectDogzItemStart) return true;
 
            if (SelectDogzItemQuality == itemConfig.ItemColor && SelectDogzItemStart == 0) return true;
 
            if (SelectDogzItemQuality == itemConfig.ItemColor && SelectDogzItemStart == itemConfig.StarLevel) return true;
 
            return false;
        }
 
        public int CompareByDogzItemPack(ItemModel start,ItemModel end)
        {
            int x = start.config.EquipPlace;
            int y = end.config.EquipPlace;
            if (x.CompareTo(y) != 0) return x.CompareTo(y);
            x = start.config.ItemColor;
            y = end.config.ItemColor;
            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
            x = start.config.StarLevel;
            y = end.config.StarLevel;
            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
            x = start.score;
            y = end.score;
            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
            return 0;
        }
 
        public List<ItemModel> selectEquipPlacelist { get; private set; }
        public List<ItemModel> GetDogzItemListByIndex(int dogzId,int index)
        {
            SinglePack singlePack = playerPack.GetSinglePack(PackType.DogzItem);
            selectEquipPlacelist.Clear();
            if (singlePack == null) return selectEquipPlacelist;
 
            var _itemColor = GetDogzEquipLimitByIndex(dogzId, index);
            var _equipPlace = GetDogzEquipPlaceByIndex(index);
            Dictionary<int, ItemModel> pairs = singlePack.GetAllItems();
            foreach (var value in pairs.Values)
            {
                if(value.config.EquipPlace == _equipPlace
                    && value.config.ItemColor >= _itemColor)
                {
                    selectEquipPlacelist.Add(value);
                }
            }
            selectEquipPlacelist.Sort(CompareByDogzItem);
            return selectEquipPlacelist;
        }
 
        public bool IsReachPutlimit(int dogzId,int itemId)
        {
            ItemConfig itemConfig = ItemConfig.Get(itemId);
            if (itemConfig == null) return true;
 
            var index = GetDogzIndexByPlace(itemConfig.EquipPlace);
            var _itemColor = GetDogzEquipLimitByIndex(dogzId, index);
            return itemConfig.ItemColor >= _itemColor ? true : false;
        }
 
        private int CompareByDogzItem(ItemModel start,ItemModel end)
        {
            int x = start.config.ItemColor;
            int y = end.config.ItemColor;
            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
            x = start.config.StarLevel;
            y = end.config.StarLevel;
            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
            x = start.score;
            y = end.score;
            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
 
            List<int> strenglist = start.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
            x = strenglist != null ? strenglist[0] : 0;
            strenglist = end.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
            y = strenglist != null ? strenglist[0] : 0;
            if (x.CompareTo(y) != 0) return -x.CompareTo(y);
 
            return 0;
        }
        #endregion
 
        #region 默认选择逻辑处理
        public void SetDefaultSelectDogz()
        {
            var configs = DogzConfig.GetValues();
            presentSelectDogz = configs[0].ID;
            if(dogzFuncRedpoint.state == RedPointState.Simple)
            {
                foreach (var key in m_DogzEquipLimit.Keys)
                {
                    Redpoint redpoint = GetSingleDogzRedpointById(key);
                    if (redpoint.state == RedPointState.Simple)
                    {
                        presentSelectDogz = key;
                        break;
                    }
                }
            }
            else
            {
                foreach(var key in dogzAssistStateDict.Keys)
                {
                    if(TryGetAssistDogzState(key))
                    {
                        presentSelectDogz = presentSelectDogz > key ? presentSelectDogz : key;
                    }
                }
            }
        }
        #endregion
 
        #region 红点逻辑处理
        public const int MAINDOGZ_REDKEY = 112;
        public const int DOGZFUNC_REDKEY = 11201;
        public const int ADDASSISTDOGZ_REDKEY = 1120100002;
        public Redpoint mainDogzRedpoint = new Redpoint(MainRedDot.RedPoint_key, MAINDOGZ_REDKEY);
        public Redpoint dogzFuncRedpoint = new Redpoint(MAINDOGZ_REDKEY,DOGZFUNC_REDKEY);
        public Redpoint addAssistDogzRedpoint = new Redpoint(DOGZFUNC_REDKEY,ADDASSISTDOGZ_REDKEY);
        private Dictionary<int, Redpoint> singleDogzRedDict = new Dictionary<int, Redpoint>();
        private Dictionary<int, Redpoint> dogzAssistRedDict = new Dictionary<int, Redpoint>();
        private Dictionary<int, Dictionary<int, Redpoint>> dogzEquipPlaceRedDict = new Dictionary<int, Dictionary<int, Redpoint>>();
        public void SetDogzAndEquipPlaceRedKey()
        {
            singleDogzRedDict.Clear();
            dogzEquipPlaceRedDict.Clear();
            dogzAssistRedDict.Clear();
            int i = 0;
            foreach(var dogzId in m_DogzEquipLimit.Keys)
            {
                i += 1;
                int dogzRedKey = DOGZFUNC_REDKEY * 100 + i;
                Redpoint dogzRedPoint = new Redpoint(DOGZFUNC_REDKEY,dogzRedKey);
                singleDogzRedDict.Add(dogzId, dogzRedPoint);
                int dogzAssistRedKey = dogzRedKey * 100 + i;
                Redpoint dogzAssistRedPoint = new Redpoint(dogzRedKey, dogzAssistRedKey);
                dogzAssistRedDict.Add(dogzId,dogzAssistRedPoint);
                Dictionary<int, Redpoint> equipPlaceRedDict = new Dictionary<int, Redpoint>();
                dogzEquipPlaceRedDict.Add(dogzId,equipPlaceRedDict);
                int equipPlaceNum = m_DogzEquipLimit[dogzId].Count;
                for (int j = 0; j < equipPlaceNum; j++)
                {
                    int equipPlaceRedKey = dogzRedKey * 10 + j;
                    Redpoint equipPlaceRedpoint = new Redpoint(dogzRedKey,equipPlaceRedKey);
                    equipPlaceRedDict.Add(j, equipPlaceRedpoint);
                }
 
            }
        }
 
        public Redpoint GetSingleDogzRedpointById(int dogzId)
        {
            Redpoint redpoint = null;
            singleDogzRedDict.TryGetValue(dogzId, out redpoint);
            return redpoint;
        }
 
        public Redpoint GetDogzAssistRedpointById(int dogzId)
        {
            Redpoint redpoint = null;
            dogzAssistRedDict.TryGetValue(dogzId,out redpoint);
            return redpoint;
        }
 
        public Redpoint GetDogzEquipPlaceRedpointById(int dogzId,int index)
        {
            Redpoint redpoint = null;
            if(dogzEquipPlaceRedDict.ContainsKey(dogzId))
            {
                dogzEquipPlaceRedDict[dogzId].TryGetValue(index, out redpoint);
            }
            return redpoint;
        }
 
        public void UpdateDogzAssistRed()
        {
            if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Dogz)) return;
 
            foreach (var value in dogzAssistRedDict.Values)
            {
                value.state = RedPointState.None;
            }
         
            bool isMaxAssistNum = GetAssistDogzCount() >= curSumAssistNum ? true : false;
            int minAlreadyAssistId = GetMinAssistDogzId();
 
            if (!isMaxAssistNum)
            {
                int maxDogzId = 0;
                foreach(var dogzId in m_DogzEquipLimit.Keys)
                {
                    var equips = GetDogzEquips(dogzId);
                    int equipNum = equips == null ? 0 : equips.Count;
                    if(equipNum >= 5 && maxDogzId < dogzId
                        && !TryGetAssistDogzState(dogzId)
                        && ((minAlreadyAssistId != 0 && dogzId > minAlreadyAssistId) || minAlreadyAssistId == 0))
                    {
                        maxDogzId = dogzId;
                    }
                }
                if(maxDogzId > 0)
                {
                    Redpoint assistRedpoint = GetDogzAssistRedpointById(maxDogzId);
                    if(assistRedpoint.state == RedPointState.None)
                    {
                        assistRedpoint.state = RedPointState.Simple;
                    }
                }
            }
            else
            {
                foreach (var dogzId in m_DogzEquipLimit.Keys)
                {
                    var equips = GetDogzEquips(dogzId);
                    int equipNum = equips == null ? 0 : equips.Count;
                    if(!TryGetAssistDogzState(dogzId) && equipNum == 5
                         && ((minAlreadyAssistId != 0 && dogzId > minAlreadyAssistId) || minAlreadyAssistId == 0))
                    {
                        Redpoint assistRedpoint = GetDogzAssistRedpointById(dogzId);
                        if (assistRedpoint.state == RedPointState.None)
                        {
                            assistRedpoint.state = RedPointState.Simple;
                        }
                        break;
                    }
                }
            }
        }
 
        public event Action UpdateDogzPutRedEvent;
        public int dogzPutRedId { get;set; }
 
        public void UpdateDogzEquipPlaceRed()
        {
            dogzPutRedId = 0;
            if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Dogz)) return;
 
            foreach (var value in dogzEquipPlaceRedDict.Values)
            {
                foreach(var value2 in value.Values)
                {
                    value2.state = RedPointState.None;
                }
            }
 
            foreach (var value in dogzAssistRedDict.Values)
            {
                if(value.state == RedPointState.Simple)
                {
                    if (UpdateDogzPutRedEvent != null)
                    {
                        UpdateDogzPutRedEvent();
                    }
                    return;
                }
            }
            int minAssistDogzId = GetMinAssistDogzId();
            bool isMaxAssistNum = GetAssistDogzCount() >= curSumAssistNum ? true : false;
            List<int> dogzIdlist = GetDogzIdByOrder();
            if (!isMaxAssistNum)
            {
                int maxEquipNum = 0;
                int spaceDogzId = 0;
                for(int i = 0; i < dogzIdlist.Count; i++)
                {
                    int dogzId = dogzIdlist[i];
                    var equips = GetDogzEquips(dogzId);
                    int equipNum = equips == null ? 0 : equips.Count;
                    if (equipNum < 5)
                    {
                        if (spaceDogzId == 0)
                        {
                            if (maxEquipNum <= equipNum)
                            {
                                maxEquipNum = equipNum;
                                spaceDogzId = dogzId;
                            }
                        }
                        else
                        {
                            if (maxEquipNum < equipNum)
                            {
                                maxEquipNum = equipNum;
                                spaceDogzId = dogzId;
                            }
                        }
                    }
                }
 
                if(spaceDogzId != 0)
                {
                    for(int i = 0; i < 5; i++)
                    {
                        ItemModel _data;
                        bool _equiped = TryGetDogzEquip(spaceDogzId, i + 101, out _data);
                        if(!_equiped)
                        {
                            GetDogzItemListByIndex(spaceDogzId,i);
                            if (selectEquipPlacelist.Count > 0)
                            {
                                Redpoint equipPlaceRedpoint = GetDogzEquipPlaceRedpointById(spaceDogzId,i);
                                if(equipPlaceRedpoint.state == RedPointState.None)
                                {
                                    dogzPutRedId = spaceDogzId;
                                    equipPlaceRedpoint.state = RedPointState.Simple;
                                }
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                int minAlreadyAssistId = GetMinAssistDogzId();
                foreach (var dogzId in m_DogzEquipLimit.Keys)
                {
                    var equips = GetDogzEquips(dogzId);
                    int equipNum = equips == null ? 0 : equips.Count;
                    bool isBetterDogz = true;
                    if(!TryGetAssistDogzState(dogzId) && dogzId > minAlreadyAssistId && equipNum < 5)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            ItemModel _data;
                            bool _equiped = TryGetDogzEquip(dogzId, i + 101, out _data);
                            if (!_equiped)
                            {
                                GetDogzItemListByIndex(dogzId,i);
                                if (selectEquipPlacelist.Count < 1)
                                {
                                    isBetterDogz = false;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        isBetterDogz = false;
                    }
 
                    if(isBetterDogz)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            ItemModel _data;
                            bool _equiped = TryGetDogzEquip(dogzId, i + 101, out _data);
                            if (!_equiped)
                            {
                                Redpoint equipPlaceRedpoint = GetDogzEquipPlaceRedpointById(dogzId, i);
                                if (equipPlaceRedpoint.state == RedPointState.None)
                                {
                                    dogzPutRedId = dogzId;
                                    equipPlaceRedpoint.state = RedPointState.Simple;
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }
 
            if(UpdateDogzPutRedEvent != null)
            {
                UpdateDogzPutRedEvent();
            }
        }
 
        public List<int> GetDogzIdByOrder()
        {
            List<int> dogzIdlist = m_DogzEquipLimit.Keys.ToList();
            int minAssistDogzId = GetMinAssistDogzId();
            if (minAssistDogzId == 0) return dogzIdlist;
 
            List<int> orderlist = new List<int>();
            for(int i = 0; i < dogzIdlist.Count; i++)
            {
                int dogzId = dogzIdlist[i];
                if(dogzId > minAssistDogzId)
                {
                    orderlist.Add(dogzId);
                }
            }
 
            for (int i = dogzIdlist.Count - 1; i > -1; i--)
            {
                int dogzId = dogzIdlist[i];
                if(!orderlist.Contains(dogzId))
                {
                    orderlist.Add(dogzId);
                }
            }
            return orderlist;
        }
 
        public void UpdateAssistNumRed()
        {
            if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Dogz)) return;
 
            if (CheckIsAddAssistNum() && !IsAddMaxAssist())
           {
                if(addAssistDogzRedpoint.state == RedPointState.None)
                {
                    addAssistDogzRedpoint.state = RedPointState.Simple;
                }
            }
          else
            {
                addAssistDogzRedpoint.state = RedPointState.None;
            }
        }
 
        #endregion
    }
}