少年修仙传客户端代码仓库
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
using vnxbqy.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using LitJson;
using UnityEngine;
//用于坐骑
 
public class HorseClass
{
    public int Lv;//坐骑等级
    public int Exp;//经验
 
}
public enum HorseEnum
{
    HorseDan = 0,//坐骑丹
    HorseDebris = 1,//坐骑碎片
    HorseStone = 2,//坐骑魂石
    //后续IL开发添加预设
    default1,
    default2,
    default3,
    default4,
    default5,
}
 
public class HorseSkillClass
{
    public int SkillID;//技能ID
    public int SkillItem;//升级技能所需道具
    public int HorseID;//坐骑ID
    public int HorseLV;//所需等级
}
 
 
public class MountModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
{
    public string _HorseIDNow = string.Empty;//获取当前的坐骑ID
    public int HorseIDNow = 0;
    public delegate void MountHA301Update(int _HorseID);
    public static event MountHA301Update Event_MountHA301U;//坐骑的更新
    public delegate void MountHA301Add(int _HorseID);
    public static event MountHA301Add Event_MountHA301A;//坐骑的添加
    public delegate void MountHA339Update(HA339_tagMCAttrFruitEatCntList info);
    public static event MountHA339Update Event_MountHA339U;//坐骑魂石的刷新
 
    public Dictionary<int, HorseSkillClass> GetMountSkillAndItem = new Dictionary<int, HorseSkillClass>();//1技能TypeID,所需的消耗物品ID
    public delegate void OnMountAlteration();//当前坐骑变更
    public static event OnMountAlteration Event_MountAlteration;
    public static event Action OnMountUieffectUpLv;//关于坐骑升级时特效播放时的调用
    public Dictionary<int, HorseClass> _DicHorse = new Dictionary<int, HorseClass>();//当前的坐骑字典
    public Dictionary<int, int> _DicMountItem = new Dictionary<int, int>();//坐骑魂石的字典
    public Dictionary<int, Redpoint> DeblockingRedPoint = new Dictionary<int, Redpoint>();//坐骑皮肤激活按钮红点
    public Dictionary<int, int> MountSkinActive = new Dictionary<int, int>();//坐骑皮肤ID激活情况
    public Dictionary<int, int> mountSkin = new Dictionary<int, int>(); //horseid 对应坐骑皮肤id 
    public int MountStoneItemId = 0;
    public bool IsOk = false;
    public List<int> ListEffectSkill = new List<int>();
    private int autoActiveHorseId = 0;
    private bool hasSendAutoActive = false;
    public int horseUpItemId { get; private set; }
    public int HorseDanExp = 0;//坐骑丹经验
    //public int[][] horseDanAttr;
    public int[] HorseAttrSort; //坐骑属性面板排序,属性和添加属性为0则不显示
    public int HorseTrainMoreCnt;
    public int horseUpItemCost = 10;
    PackModel _playerPack;
    PackModel playerPack {
        get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
    }
    public bool HorseRidingBool = false;//用来判断玩家是都在骑马
    public bool Wait = true;//等待回包(使用坐骑丹)
    public static Action<int, bool> MultipleEvent;
    public static event Action PlayerLoginOKData;
    
    private Dictionary<int, int> DicDefaultMount = new Dictionary<int, int>();
 
    Dictionary<SkillEffectGroup, int> integrationSkills = new Dictionary<SkillEffectGroup, int>();
    Dictionary<SkillEffectGroup, List<int>> integrationHorseSkills = new Dictionary<SkillEffectGroup, List<int>>();
    Dictionary<int, SkillEffectGroup> horseSkillEffectValues = new Dictionary<int, SkillEffectGroup>();
    Dictionary<int, int> horseSkills = new Dictionary<int, int>();
    public Dictionary<int, int> horseStarDict = new Dictionary<int, int>(); //坐骑幻化升星
 
    Dictionary<int, int> unLockSkinItems = new Dictionary<int, int>();
 
    public override void Init()
    {
        GetRankHorseIDs();
        playerPack.refreshItemCountEvent += OnItemRefreshEvent;
        //FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
        //MountSkillAndItem();
        MountNumberPreservation();
        string str = FuncConfigConfig.Get("MountSkillEffect").Numerical1;
        int[] listeffect = ConfigParse.GetMultipleStr<int>(str);
        ListEffectSkill.Clear();
        for (int i = 0; i < listeffect.Length; i++)
        {
            ListEffectSkill.Add(listeffect[i]);
        }
        string MountRedDotstr = FuncConfigConfig.Get("MountPetRedDot").Numerical1;
        DicDefaultMount = ConfigParse.GetDic<int, int>(MountRedDotstr);
        var funcConfig = FuncConfigConfig.Get("HorseUpItem");
        horseUpItemId = int.Parse(funcConfig.Numerical1);
        HorseDanExp = int.Parse(funcConfig.Numerical2);
        //horseDanAttr = JsonMapper.ToObject<int[][]>(funcConfig.Numerical3);
        HorseAttrSort = JsonMapper.ToObject<int[]>(funcConfig.Numerical4); //坐骑面板属性排序
        HorseTrainMoreCnt = int.Parse(funcConfig.Numerical5);
 
        var shopConfig = StoreConfig.GetStoreCfg(horseUpItemId, 1, 1);
        if (shopConfig != null)
        {
            horseUpItemCost = shopConfig.MoneyNumber;
        }
 
        funcConfig = FuncConfigConfig.Get("PetHorseSkillIntegration");
        var intArray = ConfigParse.GetMultipleStr<int>(funcConfig.Numerical2);
        for (int i = 0; i < intArray.Length; i++)
        {
            var skillConfig = SkillConfig.Get(intArray[i]);
            if (skillConfig != null)
            {
                var effectValue = SkillConfig.GetSkillEffectValue(skillConfig);
                integrationSkills.Add(effectValue, intArray[i]);
            }
        }
 
        funcConfig = FuncConfigConfig.Get("AutoActivePetHorse");
        autoActiveHorseId = int.Parse(funcConfig.Numerical2);
 
        //var _horseSkills = GetMountSkillAndItem.Keys;
        //foreach (var skillId in _horseSkills)
        //{
        //    var skillConfig = SkillConfig.Get(skillId);
        //    var effectValue = SkillConfig.GetSkillEffectValue(skillConfig);
 
        //    if (integrationSkills.ContainsKey(effectValue))
        //    {
        //        List<int> skills = null;
        //        if (!integrationHorseSkills.TryGetValue(effectValue, out skills))
        //        {
        //            skills = new List<int>();
        //            integrationHorseSkills.Add(effectValue, skills);
        //        }
        //        skills.Add(skillId);
        //    }
 
        //    horseSkills.Add(skillId, GetMountSkillAndItem[skillId].HorseID);
        //    horseSkillEffectValues.Add(skillId, effectValue);
        //}
 
        mountSkin.Clear();
        MountSkinActive.Clear();
        foreach (var config in HorseSkinPlusConfig.GetValues())
        {
            mountSkin[config.HorseID] = config.ID;
            MountSkinActive[config.ID] = 0;
        }
        unLockSkinItems.Clear();
        foreach (var config in HorseConfig.GetValues())
        {
            if (mountSkin.ContainsKey(config.HorseID))
            {
                unLockSkinItems[config.UnlockItemID] = mountSkin[config.HorseID];
            }
        }
    }
 
    public override void UnInit()
    {
        playerPack.refreshItemCountEvent -= OnItemRefreshEvent;
        //FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
    }
 
 
 
    public void OnBeforePlayerDataInitialize()
    {
        IsOk = false;
        hasSendAutoActive = false;
        _HorseIDNow = string.Empty;
        HorseIDNow = 0;
        _DicHorse.Clear();
        HorseRidingBool = false;
        Wait = true;
        MountHA301MorePack = false;
        horseStarDict.Clear();
    }
 
    public void OnPlayerLoginOk()
    {
        GlobalTimeEvent.Instance.secondEvent -= secondEvent;
        GlobalTimeEvent.Instance.secondEvent += secondEvent;
        IsOk = true;
 
        RefreshCurrentMount(playerPack.GetItemByIndex(PackType.Equip, EquipPlaceMapConfig.GetServerPlace(0, (int)RoleEquipType.Mount)));
        MountStoneRed();
        MountDanRed();
        var singPack = playerPack.GetSinglePack(PackType.Item);
        if (singPack != null)
        {
            foreach (var index in singPack.GetAllItems().Keys)
            {
                OnItemRefreshEventLogin(singPack.type, index, singPack.GetAllItems()[index].itemId);
            }
        }
        if (PlayerLoginOKData != null)
        {
            PlayerLoginOKData();
        }
    }
 
    private DateTime dateTimeA;
    private void secondEvent()
    {
        if (!Wait)
        {
            TimeSpan timeS = DateTime.Now - dateTimeA;
            if (timeS.Seconds >= 2f)
            {
                Wait = true;
            }
        }
        else
        {
            dateTimeA = DateTime.Now;
        }
    }
 
    List<HorseConfig> Hconfigs = new List<HorseConfig>();
 
    public int RedPoint_HuaxingID = MainRedDot.RedPoint_MountPackKey * 10; //化形红点
    int RedPoint_DanID = MainRedDot.RedPoint_MountPackKey * 10 + 1; //可用坐骑丹红点
    Redpoint RedPoint_Dan;
    private void MountNumberPreservation()//用来对坐骑个数的保存
    {
        Redpoint RedPoint_Huaxing = new Redpoint(MainRedDot.RedPoint_MountPackKey, RedPoint_HuaxingID);
        RedPoint_Dan = new Redpoint(MainRedDot.RedPoint_MountPackKey, RedPoint_DanID);
        DeblockingRedPoint.Clear();
        var skinConfigs = HorseSkinPlusConfig.GetValues();
        foreach (var config in skinConfigs)
        {
 
            int RedPoint_Mountkey1 = RedPoint_HuaxingID * 1000 + config.ID;
            Redpoint redPointMountStare1 = new Redpoint(RedPoint_HuaxingID, RedPoint_Mountkey1);
            DeblockingRedPoint.Add(config.ID, redPointMountStare1);
        }
 
    }
 
    private const int Redpoint_key2 = MainRedDot.RedPoint_MountPackKey * 10 + 2;
    public Redpoint redPointStre2 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key2);//坐骑兽魂
 
    private const int Redpoint_key3 = MainRedDot.RedPoint_MountPackKey * 10 + 3;
    public Redpoint redPointStre3 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key3);//坐骑培养
 
    public event Action HorseExpItemRefresh;
    private void OnItemRefreshEvent(PackType type, int index, int id)
    {
        if (type == PackType.Equip)
        {
            RefreshCurrentMount(playerPack.GetItemByIndex(type, index));
        }
 
        if (type == PackType.Item)
        {
            if (id == horseUpItemId)
            {
                MountDanRed();
                if (HorseExpItemRefresh != null)
                    HorseExpItemRefresh();
            }
 
            if (unLockSkinItems.ContainsKey(id))
            {
                int activeID = unLockSkinItems[id];
                if (MountSkinActive[activeID] == 0)
                {
                    DeblockingRedPoint[activeID].state = RedPointState.Simple;
                }
                else
                {
                    RefreshStarRedpoint(id);
                }
 
            }
            ForsterHorseRed(id);
 
 
            //var config = HorseConfig.Get(autoActiveHorseId);
            //if (config != null && id == config.UnlockItemID)
            //{
            //    TryAutoActiveHorse();
            //}
        }
    }
 
    private void OnItemRefreshEventLogin(PackType type, int index, int id)
    {
 
        if (type == PackType.Item)
        {
            if (unLockSkinItems.ContainsKey(id))
            {
                int activeID = unLockSkinItems[id];
                if (MountSkinActive[activeID] == 0)
                {
                    DeblockingRedPoint[activeID].state = RedPointState.Simple;
                }
                else
                {
                    RefreshStarRedpoint(id);
                }
            }
            ForsterHorseRed(id);
 
        }
    }
 
    //升星和解锁共用红点
    void RefreshStarRedpoint(int itemID)
    {
        int activeID = unLockSkinItems[itemID];
        int horseID = HorseConfig.GetItemUnLockHorse(itemID);
        if (!HorseStarUpConfig.horseIDToIDs.ContainsKey(horseID))
            return;
        if (!isMountSkinActive(horseID))
            return;
 
        DeblockingRedPoint[activeID].state = RedPointState.None;
 
        int star = 0;
        horseStarDict.TryGetValue(horseID, out star);
        //满星
        if (star == HorseStarUpConfig.horseIDToIDs[horseID].Count)
            return;
 
        var id = HorseStarUpConfig.horseIDToIDs[horseID][star];
        var nextStarConfig = HorseStarUpConfig.Get(id);
        var awards = nextStarConfig.StarUpNeedItemList;
        for (int i = 0; i < awards.Length; i++)
        {
            if (playerPack.GetItemCountByID(PackType.Item, awards[i][0]) < awards[i][1])
                return;
        }
        DeblockingRedPoint[activeID].state = RedPointState.Simple;
    }
 
    //private void OnFuncStateChangeEvent(int funcId)
    //{
    //    if (funcId == (int)FuncOpenEnum.Mounts)
    //    {
    //        TryAutoActiveHorse();
    //    }
    //}
 
    //private void TryAutoActiveHorse()
    //{
    //    if (IsOk && FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Mounts)
    //        && !_DicHorse.ContainsKey(autoActiveHorseId) && !hasSendAutoActive)
    //    {
    //        var horseConfig = HorseConfig.Get(autoActiveHorseId);
    //        if (horseConfig != null)
    //        {
    //            var itemCount = playerPack.GetItemCountByID(PackType.Item, horseConfig.UnlockItemID);
    //            if (itemCount >= horseConfig.UnlockItemCnt)
    //            {
    //                hasSendAutoActive = true;
    //                var pak = new CA501_tagPlayerActivateHorse();
    //                pak.HorseID = (uint)autoActiveHorseId;
    //                GameNetSystem.Instance.SendInfo(pak);
    //            }
    //        }
    //    }
    //}
    //培养石头
    public void ForsterHorseRed(int id)//培养石头红点
    {
        for (int i = 0; i < GeneralDefine.HorseTrainIDList.Length; i++)
        {
            if (GeneralDefine.HorseTrainIDList[i] == id)
            {
                redPointStre3.state = RedPointState.None;
                if (FosterModel.Instance.GetHorseRedPointUpdate(i, id))
                {
                    redPointStre3.state = RedPointState.Simple;
                }
                return;
            }
        }
        
    }
    public void MountStoneRed()//坐骑魂石红点
    {
        redPointStre2.state = RedPointState.None;
        if (!FuncOpen.Instance.IsFuncOpen(8))
           return;
        int type = 0;
        foreach (var key in _DicMountItem.Keys)
        {
           var AttrFruit = AttrFruitConfig.Get(key);
           if (AttrFruit == null)
           {
               continue;
           }
           if (_DicMountItem[key] >= AttrFruit.basicUseLimit)
           {
               continue;
           }
           type += playerPack.GetItemCountByID(PackType.Item, key);
        }
        if (type > 0)
        {
           redPointStre2.state = RedPointState.Simple;
           return;
        }
    }
 
    private void MountDanRed()//关于坐骑丹红点
    {
        RedPoint_Dan.state = RedPointState.None;
        if (!FuncOpen.Instance.IsFuncOpen(8))
        {
            return;
        }
        List<int> IntList = new List<int>();
        int number = playerPack.GetItemCountByID(PackType.Item, horseUpItemId);
        var trainCnt = GetTrainCount();
        RedPoint_Dan.state = (trainCnt == 0 || number < trainCnt) ? RedPointState.None : RedPointState.Simple;
 
    }
 
 
    private int GetSkillLvDis(int MountId)//获取离升级最近的技能等级
    {
        int SkillLv = 0;
 
        foreach (var key in GetMountSkillAndItem.Keys)
        {
            if (_DicHorse.ContainsKey(MountId) && GetMountSkillAndItem[key].HorseID == MountId)
            {
                if (GetMountSkillAndItem[key].HorseLV > _DicHorse[MountId].Lv)
                {
                    SkillLv = GetMountSkillAndItem[key].HorseLV;
                    return SkillLv;
                }
            }
        }
        return SkillLv;
    }
 
    public int GetMountSkillMaxLV(int MountId)//获取坐骑最大技能等级
    {
        int SkillLv = 0;
        foreach (var key in GetMountSkillAndItem.Keys)
        {
            if (GetMountSkillAndItem[key].HorseID == MountId)
            {
                if (GetMountSkillAndItem[key].HorseLV > SkillLv)
                {
                    SkillLv = GetMountSkillAndItem[key].HorseLV;
                }
 
            }
        }
        return SkillLv;
    }
 
    void RefreshCurrentMount(ItemModel info)//获取当前的坐骑
    {
        if (info == null)
        {
            return;
        }
 
        if (info.config.EquipPlace == (byte)RoleEquipType.Mount)//坐骑位置19
        {
            if (Hconfigs.Count <= 0)
            {
                Hconfigs = HorseConfig.GetValues();
            }
 
            foreach (var config in Hconfigs)
            {
                if (config.ItemID == info.itemId)
                {
                    HorseIDNow = config.HorseID;
                    _HorseIDNow = config.HorseID.ToString();
                    if (Event_MountAlteration != null && IsOk)
                    {
                        Event_MountAlteration();
                    }
                }
            }
        }
 
        
    }
 
    public int HorseLV = 1;
    public int HorseEatCount = 0;   //乘以每个丹的经验就是当前经验
    //public uint SkinPlusState = 0;
    public uint[] horseSkinArray;   //坐骑幻化激活支持超过31
    public event Action onHorseInfoUpdate;
    public event Action onHorseLVUP;
    public event Action onMountSkinActive;
    public int NextTrainCount = 0;
    public bool MountHA301MorePack = false;
 
    public void CallMountAlteration()
    {
        if (Event_MountAlteration != null)
            Event_MountAlteration();
    }
 
    public void MountHA301(HA301_tagTrainHorseData info)//已拥有的坐骑(获得与刷新)
    {
        bool islvup = false;
        bool isSkinActive = false;
        if (MountHA301MorePack && info.LV > HorseLV)
        {
            islvup = true;
            
        }
 
        if (MountHA301MorePack && info.SkinPlusStateList != horseSkinArray)
        {
            isSkinActive = true;
        }
        HorseLV = info.LV;
        if (islvup)
        {
            MountDanRed();
        }
        HorseEatCount = (int)info.EatItemCount;
        horseSkinArray = info.SkinPlusStateList;
 
        RefreshHorseAllAttr();
        
        if (onHorseInfoUpdate != null)
            onHorseInfoUpdate();
 
        if (islvup && onHorseLVUP != null)
            onHorseLVUP();
 
        if (isSkinActive && onMountSkinActive != null)
        {
            CalcMountSkinActive();
            onMountSkinActive();
        }
        if (!MountHA301MorePack)
        {
            CalcMountSkinActive();
        }
        MountHA301MorePack = true;
    }
 
    private void CalcMountSkinActive()
    {
        MountSkinActive.Clear();
        foreach (var config in HorseSkinPlusConfig.GetValues())
        {
            MountSkinActive[config.ID] = isMountSkinActiveByID(config.ID) ? 1 : 0;
        }
 
        foreach (var redpoint in DeblockingRedPoint)
        {
            if (isMountSkinActiveByID(redpoint.Key))
            {
                redpoint.Value.state = RedPointState.None;
            }
        }
 
    }
 
    public void MountHA339(HA339_tagMCAttrFruitEatCntList info)//坐骑魂石
    {
        for (int i = 0; i < info.count; i++)
        {
            var configItem = ItemConfig.Get((int)info.EatCntList[i].ItemID);
            if (configItem == null)
            {
                continue;
            }
 
            if (_DicMountItem.ContainsKey((int)info.EatCntList[i].ItemID))
            {
                _DicMountItem[(int)info.EatCntList[i].ItemID] = (int)info.EatCntList[i].EatCnt;
                if (Event_MountHA339U != null)
                    Event_MountHA339U(info);//坐骑魂石的刷新
            }
            else
            {
                if (configItem.Type == 22)
                {
                    _DicMountItem.Add((int)info.EatCntList[i].ItemID, (int)info.EatCntList[i].EatCnt);
                }
            }
        }
        MountStoneRed();
    }
    public int GetAllMountAttack()//得到所有坐骑的攻击
    {
        Dictionary<int, int> dicStone = Bonuses();
        if (_DicHorse.Count == 0)
        {
            return dicStone[7];
        }
        else
        {
            int _AttT = 0;//攻击
 
            return _AttT + dicStone[7];
        }
    }
    Dictionary<int, int> Bonuses()//属性加成
    {
        Dictionary<int, int> dic = new Dictionary<int, int>();
        dic.Clear();
        dic.Add(6, 0);//生命
        dic.Add(7, 0);//攻击
        dic.Add(8, 0);//防御
        foreach (int key in _DicMountItem.Keys)
        {
            if (_DicMountItem[key] != 0)
            {
                ItemConfig itemModel = ItemConfig.Get(key);
                if (dic.ContainsKey(itemModel.Effect1))
                {
                    dic[itemModel.Effect1] += itemModel.EffectValueA1 * _DicMountItem[key];
                }
                if (dic.ContainsKey(itemModel.Effect2))
                {
                    dic[itemModel.Effect2] += itemModel.EffectValueA2 * _DicMountItem[key];
                }
                if (dic.ContainsKey(itemModel.Effect3))
                {
                    dic[itemModel.Effect3] += itemModel.EffectValueA3 * _DicMountItem[key];
                }
                if (dic.ContainsKey(itemModel.Effect4))
                {
                    dic[itemModel.Effect4] += itemModel.EffectValueA4 * _DicMountItem[key];
                }
                if (dic.ContainsKey(itemModel.Effect5))
                {
                    dic[itemModel.Effect5] += itemModel.EffectValueA5 * _DicMountItem[key];
                }
            }
        }
        return dic;
    }
 
    public bool IsHint(HorseEnum horseEnum, int id = 0)//True提示,False不提示
    {
        bool iSHint = false;
        switch (horseEnum)
        {
            case HorseEnum.HorseDan:
                foreach (var key in _DicHorse.Keys)
                {
                    HorseConfig horseConfig = HorseConfig.Get(key);
                    if (horseConfig.MaxLV > _DicHorse[key].Lv)
                    {
                        iSHint = true;
                    }
                }
                return iSHint;
            case HorseEnum.HorseDebris:
                if (Hconfigs.Count <= 0)
                {
                    Hconfigs = HorseConfig.GetValues();
                }
                foreach (var value in Hconfigs)
                {
                    if (value.UnlockItemID == id)
                    {
                        if (!_DicHorse.ContainsKey(value.HorseID))
                        {
                            iSHint = true;
                        }
                    }
                }
                return iSHint;
            case HorseEnum.HorseStone:
                int _maxuse = AttrFruitConfig.Get(id).basicUseLimit;
                if (_DicMountItem.ContainsKey(id))
                {
                    if (_maxuse > _DicMountItem[id])
                    {
                        iSHint = true;
                    }
                }
                return iSHint;
            default:
                return true;
        }
    }
    //ChooseType;    // 1-按等阶,2-按幻化
    //LVID;    // 阶等级或幻化ID
    public void AppearanceSwitch(byte lvID, byte ChooseType)//坐骑外观切换
    {
        CA502_tagPlayerChooseHorse _tagCA502 = new CA502_tagPlayerChooseHorse();
        _tagCA502.LVID = lvID;
        _tagCA502.ChooseType = ChooseType;
        GameNetSystem.Instance.SendInfo(_tagCA502);
    }
 
    
    public void MountDanUse(int Number, bool IsAutoBuy = false)//是否自动购买
    {
        LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(7, horseUpItemId, GetTrainCount(), 1, 0);
        CA527_tagCMHorseUp _tagC527 = new CA527_tagCMHorseUp();//向服务端发包坐骑经验单
        _tagC527.UseItemCnt = (ushort)Number;
        if (IsAutoBuy)
        {
            _tagC527.IsAutoBuy = 1;
        }
        GameNetSystem.Instance.SendInfo(_tagC527);
    }
 
    public int IsHorsePanelState()
    {
        int Type = 0;
        foreach (var value in DeblockingRedPoint.Values)
        {
            if (value.state == RedPointState.Simple)
            {
                Type = 2;
                return Type;
            }
        }
        if (MainRedDot.Instance.redPointMountFunc.state == RedPointState.Simple)
        {
            Type = 1;
            return Type;
        }
        return Type;
    }
 
    #region 预览坐骑碎片属性
    // 坐骑皮肤属性
    public Dictionary<int, int> GetMountAttrAddDict(int mountCode)
    {
        var mountAttrDict = new Dictionary<int, int>();
        mountAttrDict.Clear();
        var config = HorseSkinPlusConfig.Get(mountSkin[mountCode]);
        int showIndex = 0;
        foreach (var attrID in config.AttrType)
        {
            mountAttrDict[attrID] = config.AttrValue[showIndex];
            showIndex++;
        }
 
        return mountAttrDict;
    }
 
    // 坐骑皮肤战力
    public int GetMountSkinFightPower(int mountCode)
    {
        var config = HorseSkinPlusConfig.Get(mountSkin[mountCode]);
        return (UIHelper.GetFightPower(GetMountAttrAddDict(mountCode)) + config.InitFightPower);
    }
 
    #endregion
 
    #region 技能整合
    public bool TryGetIntegrationSkill(SkillEffectGroup effect, out int skillId)
    {
        return integrationSkills.TryGetValue(effect, out skillId);
    }
 
    public bool TryGetHorseSkills(SkillEffectGroup effect, out List<int> skills)
    {
        return integrationHorseSkills.TryGetValue(effect, out skills);
    }
 
    public SkillEffectGroup GetSkillEffectGroup(int skillId)
    {
        if (horseSkillEffectValues.ContainsKey(skillId))
        {
            return horseSkillEffectValues[skillId];
        }
        return default(SkillEffectGroup);
    }
 
    public bool IsSkillUnlock(int skillId)
    {
        var config = SkillConfig.Get(skillId);
        if (config == null)
        {
            return false;
        }
        var effect = SkillConfig.GetSkillEffectValue(config);
 
        if (integrationHorseSkills.ContainsKey(effect)
            && !integrationHorseSkills[effect].Contains(skillId))
        {
            var skills = integrationHorseSkills[effect];
            foreach (var id in skills)
            {
                if (IsSkillUnlock(id))
                {
                    return true;
                }
            }
        }
        else
        {
            if (GetMountSkillAndItem.ContainsKey(skillId))
            {
                var horseId = GetMountSkillAndItem[skillId].HorseID;
                if (_DicHorse.ContainsKey(horseId))
                {
                    var horseInfo = _DicHorse[horseId];
                    if (horseInfo.Lv >= GetSkillUnlockLevel(skillId))
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
 
    public int GetSkillUnlockLevel(int skillId)
    {
        if (GetMountSkillAndItem.ContainsKey(skillId))
        {
            return GetMountSkillAndItem[skillId].HorseLV;
        }
        return 0;
    }
    #endregion
 
    public bool IsHorseMaxLevel(int horseId)
    {
        if (_DicHorse.ContainsKey(horseId))
        {
            var horseConfig = HorseConfig.Get(horseId);
            return _DicHorse[horseId].Lv >= horseConfig.MaxLV;
        }
        else
        {
            return false;
        }
    }
 
    public bool IsHorseUnlock(int horseId)
    {
        return _DicHorse.ContainsKey(horseId);
    }
 
    private Dictionary<int, int> HorseAllAttr = new Dictionary<int, int>();
    private int activeAllSkinAddPower = 0;   //额外增加的坐骑皮肤战力
    //坐骑属性:丹经验属性,升阶属性,皮肤属性
    public Dictionary<int, int> RefreshHorseAllAttr()
    {
        HorseAllAttr.Clear();
        activeAllSkinAddPower = 0;
 
        //丹经验属性
        for (int i = 1; i <= HorseLV; i++)
        {
            var config = HorseLVUpConfig.Get(i);
            var eatCnt = 0;
            if (config.useCnt == 0)
            {
                //最高级不计算
                continue;
            }
            else if (i == HorseLV)
            {
 
                //当前等级取封包数量
                eatCnt = HorseEatCount / config.useCnt;
            }
            else
            {
                eatCnt = config.NeedEatCount / config.useCnt;
            }
 
            for (int j = 0; j < config.UpItemAttrType.Length; j++)
            {
                var upKey = config.UpItemAttrType[j];
                if (!HorseAllAttr.ContainsKey(upKey))
                {
                    HorseAllAttr[upKey] = 0;
                }
 
                HorseAllAttr[upKey] = HorseAllAttr[upKey] + eatCnt * config.UpItemAttrValue[j];
            }
        }
 
        //升阶属性
        for (int k = 1; k <= HorseLV; k++)
        {
            var horseLVConfig = HorseLVUpConfig.Get(k);
            for (int i = 0; i < horseLVConfig.LVAttrType.Length; i++)
            {
                if (!HorseAllAttr.ContainsKey(horseLVConfig.LVAttrType[i]))
                {
                    HorseAllAttr[horseLVConfig.LVAttrType[i]] = 0;
                }
 
                HorseAllAttr[horseLVConfig.LVAttrType[i]] = HorseAllAttr[horseLVConfig.LVAttrType[i]] + horseLVConfig.LVAttrValue[i];
            }
        }
        //皮肤属性
        foreach (var byteID in HorseSkinPlusConfig.GetKeys())
        {
            if (!isMountSkinActiveByID(int.Parse(byteID)))
                //未激活皮肤
                continue;
 
            var config = HorseSkinPlusConfig.Get(byteID);
            for (int i = 0; i < config.AttrType.Length; i++)
            {
                if (!HorseAllAttr.ContainsKey(config.AttrType[i]))
                {
                    HorseAllAttr[config.AttrType[i]] = 0;
                }
                HorseAllAttr[config.AttrType[i]] = HorseAllAttr[config.AttrType[i]] + config.AttrValue[i];
            }
            activeAllSkinAddPower += config.InitFightPower;
        }
 
        return HorseAllAttr;
    }
 
    public bool isMountSkinActive(int horseID)
    {
        if (!mountSkin.ContainsKey(horseID))
        {
            return false;
        }
 
        return isMountSkinActiveByID(mountSkin[horseID]);
    }
 
    public bool isMountSkinActiveByID(int ID)
    {
        if (horseSkinArray == null || horseSkinArray.Length == 0)
            return false;
 
        int index = ID / 31;
        int value = ID % 31;
        if (((int)Math.Pow(2, value) & horseSkinArray[index]) <= 0)
            //未激活皮肤
            return false;
 
        return true;
    }
 
    //额外增加战力
    public int GetMountSkinAddFightPower()
    {
        int fightPower = 0;
        foreach (var config in HorseSkinPlusConfig.GetValues())
        {
            if (isMountSkinActiveByID(config.ID))
            {
                fightPower += config.InitFightPower;
            }
        }
 
        return fightPower;
    }
 
 
    public Dictionary<int, int> GetHorseAllAttr()
    {
        if (HorseAllAttr.Keys.Count == 0)
            RefreshHorseAllAttr();
        return HorseAllAttr;
    }
    //UIHelper.GetFightPower(FightDic)
 
    public int GetHorseFightPower()
    {
        var allAttrDict = GetHorseAllAttr();
        return UIHelper.GetFightPower(allAttrDict) + activeAllSkinAddPower;
    }
    //默认驯养一颗,当数量大于X 全部驯养(不超过2阶)
    public int GetTrainCount()
    {
        var config = HorseLVUpConfig.Get(HorseLV);
        if (config.NeedEatCount == 0)
        {
            //已满级
            return 0;
        }
 
        //int number = playerPack.GetItemCountByID(PackType.Item, horseUpItemId);
 
        //if (number > HorseTrainMoreCnt)
        //{
        //    trainCount = number;
        //    if (HorseEatCount + number >= config.NeedEatCount)
        //    {
        //        //有升阶的情况,最多一阶
        //        var Nextconfig = HorseLVUpConfig.Get(HorseLV + 1);
        //        if (Nextconfig.NeedEatCount == 0)
        //        {
        //            //升级后满级
        //            trainCount = config.NeedEatCount - HorseEatCount;
        //        }
        //        else if (number >= (config.NeedEatCount - HorseEatCount + Nextconfig.NeedEatCount))
        //        {
        //            //超过2阶的情况
        //            trainCount = config.NeedEatCount - HorseEatCount + Nextconfig.NeedEatCount - 1;
        //        }
        //    }
        //}
 
        var nextConfig = HorseLVUpConfig.Get(HorseLV + 1);
        if (nextConfig.NeedEatCount == 0)
        {
            // 下一阶满级,只扣剩余所需不超过单次的材料数量
            if (config.NeedEatCount - HorseEatCount < config.useCnt)
            {
                return config.NeedEatCount - HorseEatCount;
            }
        }
 
        return config.useCnt;
    }
 
    public Dictionary<int, int> GetNextTrainAttr()
    {
        Dictionary<int, int> nextTrainAttr = new Dictionary<int, int>();
        var NextTrainCount = GetTrainCount();
        if (NextTrainCount == 0)
        {
            return nextTrainAttr;
        }
 
        var config = HorseLVUpConfig.Get(HorseLV);
        for (int i = 0; i < config.UpItemAttrType.Length; i++)
        {
            nextTrainAttr[config.UpItemAttrType[i]] = config.UpItemAttrValue[i];
        }
 
        if (HorseEatCount + NextTrainCount >= config.NeedEatCount)
        {
            //有升阶的情况
            var Nextconfig = HorseLVUpConfig.Get(HorseLV + 1);
 
            for (int i = 0; i < Nextconfig.LVAttrType.Length; i++)
            {
                if (!nextTrainAttr.ContainsKey(Nextconfig.LVAttrType[i]))
                {
                    nextTrainAttr[Nextconfig.LVAttrType[i]] = 0;
                }
                nextTrainAttr[Nextconfig.LVAttrType[i]] = nextTrainAttr[Nextconfig.LVAttrType[i]] + Nextconfig.LVAttrValue[i];
            }
        }
 
        return nextTrainAttr;
    }
    //获取升阶的所有坐骑ID
    public List<int> RankHorseIDList = new List<int>();
    private void GetRankHorseIDs()
    {
        RankHorseIDList.Clear();
        foreach (var horseConfig in HorseLVUpConfig.GetValues())
        {
            RankHorseIDList.Add(horseConfig.HorseID);
        }
    }
 
    //坐骑幻化升星
    public void UpdateHorseStarInfo(HA3CD_tagMCHorseStarInfo netPack)
    {
        for (int i = 0; i < netPack.HorseStarList.Length; i++)
        {
            horseStarDict[(int)netPack.HorseStarList[i].HorseID] = netPack.HorseStarList[i].Star;
        }
        onMountSkinActive?.Invoke();
 
        foreach (var id in unLockSkinItems.Keys)
        {
            RefreshStarRedpoint(id);
        }
    }
 
    //坐骑幻化物品是否可用于觉醒
    public bool IsHorseSkinCanAwake(int horseID)
    {
        if (!isMountSkinActive(horseID))
        {
            return false;
        }
 
        if (!HorseStarUpConfig.horseIDToIDs.ContainsKey(horseID))
            return true;
 
        int star = 0;
        horseStarDict.TryGetValue(horseID, out star);
        //满星
        if (star != HorseStarUpConfig.horseIDToIDs[horseID].Count)
            return false;
 
        return true;
    }
}