少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
using Snxxz.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
using UnityEngine;
//用于坐骑
[XLua.LuaCallCSharp]
public class HorseClass
{
    public int Lv;//坐骑等级
    public int Exp;//经验
 
}
public enum HorseEnum
{
    HorseDan = 0,//坐骑丹
    HorseDebris = 1,//坐骑碎片
    HorseStone = 2,//坐骑魂石
}
 
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(string NowMount);//当前坐骑变更
    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> mountRedpoint = new Dictionary<int, Redpoint>();//坐骑外观切换红点
    public Dictionary<int, Redpoint> DeblockingRedPoint = new Dictionary<int, Redpoint>();//激活按钮红点
    public Dictionary<int, Redpoint> ASingleFeedRedPoint = new Dictionary<int, Redpoint>();//单次喂养红点
    private List<HorseConfig> SortMount = new List<HorseConfig>();//用于红点排序
    public int MountStoneItemId = 0;
    public bool IsOk = false;
    public List<int> ListEffectSkill = new List<int>();
    private int HorseDanExp = 0;//坐骑丹经验
    private int autoActiveHorseId = 0;
    private bool hasSendAutoActive = false;
    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 override void Init()
    {
        ToAddSorting();
        playerPack.refreshItemCountEvent += OnItemRefreshEvent;
        MountWin.RedPointMountDan += RedPointMountDan;
        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);
        string HorseUpItem = FuncConfigConfig.Get("HorseUpItem").Numerical2;
        HorseDanExp = int.Parse(HorseUpItem);
 
        var 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);
        }
    }
 
    public override void UnInit()
    {
        MountWin.RedPointMountDan -= RedPointMountDan;
        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;
    }
 
    public void OnPlayerLoginOk()
    {
        GlobalTimeEvent.Instance.secondEvent -= secondEvent;
        GlobalTimeEvent.Instance.secondEvent += secondEvent;
        IsOk = true;
        SinglePack singPack = playerPack.GetSinglePack(PackType.Equip);
        if (singPack == null) return;
        foreach (var index in singPack.GetAllItems().Keys)
        {
            OnItemRefreshEvent(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>();
    List<HorseUpConfig> Uconfigs = new List<HorseUpConfig>();
    private void MountNumberPreservation()//用来对坐骑个数的保存
    {
        if (mountRedpoint.Count != 0)
            return;
 
        // var configs = HorseConfig.GetValues();
        if (Hconfigs.Count <= 0)
        {
            Hconfigs = HorseConfig.GetValues();
        }
        int type = 0;
        foreach (var config in Hconfigs)
        {
            if (!mountRedpoint.ContainsKey(config.HorseID))
            {
                type += 1;
                int mountID = config.HorseID;
                int RedPoint_Mountkey = MainRedDot.RedPoint_MountPackKey * 10 + mountID;
                Redpoint redPointMountStare = new Redpoint(Redpoint_key1, RedPoint_Mountkey);
                mountRedpoint.Add(mountID, redPointMountStare);
 
                int RedPoint_Mountkey1 = RedPoint_Mountkey * 10 + type;
                Redpoint redPointMountStare1 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey1);
                DeblockingRedPoint.Add(mountID, redPointMountStare1);
 
                int RedPoint_Mountkey2 = RedPoint_Mountkey1 * 10 + type;
                Redpoint redPointMountStare2 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey2);
                ASingleFeedRedPoint.Add(mountID, redPointMountStare2);
            }
 
        }
 
    }
    private void MountChangeRedPoint()//坐骑激活红点
    {
        foreach (var key in DeblockingRedPoint.Keys)
        {
            DeblockingRedPoint[key].state = RedPointState.None;
        }
        if (!FuncOpen.Instance.IsFuncOpen(8))
        {
            return;
        }
        if (Hconfigs.Count <= 0)
        {
            Hconfigs = HorseConfig.GetValues();
        }
        //  var configs = HorseConfig.GetValues();
        foreach (var config in Hconfigs)
        {
            int unlockItemID = config.UnlockItemID;
            int itemCount = playerPack.GetItemCountByID(PackType.Item, unlockItemID);
            int unlockItemCnt = config.UnlockItemCnt;
            if (itemCount >= unlockItemCnt && !_DicHorse.ContainsKey(config.HorseID))
            {
                DeblockingRedPoint[config.HorseID].state = RedPointState.Simple;
            }
        }
    }
 
    void MountSkillAndItem()//获取坐骑技能
    {
        if (GetMountSkillAndItem.Count != 0)
            return;
        if (Uconfigs.Count <= 0)
        {
            Uconfigs = HorseUpConfig.GetValues();
        }
        //var configs = HorseUpConfig.GetValues();
        foreach (var config in Uconfigs)
        {
            if (!HorseConfig.Has(config.HorseID))
            {
                continue;
            }
 
            for (int i = 0; i < config.SkillID.Length; i++)
            {
                int skillID = config.SkillID[i];
                if (skillID != 0 && !GetMountSkillAndItem.ContainsKey(skillID))
                {
                    SkillConfig _skillModel = SkillConfig.Get(skillID);
                    if (_skillModel == null)
                    {
                        Debug.Log(skillID);
                    }
 
                    HorseSkillClass horseSkillClass = new HorseSkillClass();
                    horseSkillClass.SkillID = skillID;
                    horseSkillClass.SkillItem = _skillModel.ExAttr4;
                    horseSkillClass.HorseID = config.HorseID;
                    horseSkillClass.HorseLV = config.LV;
                    GetMountSkillAndItem.Add(skillID, horseSkillClass);
                }
            }
        }
    }
    private const int Redpoint_key1 = 1050101;
    public Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key1);//坐骑外观
    private const int Redpoint_key2 = 1050102;
    public Redpoint redPointStre2 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key2);//坐骑兽魂
    private void OnItemRefreshEvent(PackType type, int index, int id)
    {
        if (type == PackType.Equip)
        {
            RefreshCurrentMount(playerPack.GetItemByIndex(type, index));
        }
 
        if (type == PackType.Item)
        {
            if (_DicMountItem.ContainsKey(id))
            {
                MountStoneRed();
            }
            MountChangeRedPoint();
            MountDanRed();
 
            var config = HorseConfig.Get(autoActiveHorseId);
            if (config != null && id == config.UnlockItemID)
            {
                TryAutoActiveHorse();
            }
        }
    }
 
    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);
                }
            }
        }
    }
 
    private 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 RedPointMountDan()
    {
        MountDanRed();
    }
 
    private void ToAddSorting()
    {
        SortMount.Clear();
        if (Hconfigs.Count <= 0)
        {
            Hconfigs = HorseConfig.GetValues();
        }
        SortMount = Hconfigs;
        SortMount.Sort(Compare);
    }
    int Compare(HorseConfig x, HorseConfig y)//数组排列
    {
        if (x.Sort.CompareTo(y.Sort) != 0)
        {
            return x.Sort.CompareTo(y.Sort);
        }
        return 1;
    }
    private void MountDanRed()//关于坐骑丹红点
    {
        foreach (var key in ASingleFeedRedPoint.Keys)
        {
            ASingleFeedRedPoint[key].state = RedPointState.None;
        }
        if (!FuncOpen.Instance.IsFuncOpen(8) || _DicHorse.Count == 0)
        {
            return;
        }
        List<int> IntList = new List<int>();
        FuncConfigConfig _tagfun = FuncConfigConfig.Get("HorseUpItem");
        ItemConfig _tagchine = ItemConfig.Get(int.Parse(_tagfun.Numerical1));
        int number = playerPack.GetItemCountByID(PackType.Item, _tagchine.ID);
        for (int i = 0; i < SortMount.Count; i++)
        {
            int horseID = SortMount[i].HorseID;
            int MaxLv = HorseConfig.Get(horseID).MaxLV;
            if (_DicHorse.ContainsKey(horseID) && _DicHorse[horseID].Lv < MaxLv)
            {
                int _NeedExp = HorseUpConfig.GetHorseIDAndLV(horseID, (_DicHorse[horseID].Lv)).NeedExp;
                int NeedExp = _NeedExp - _DicHorse[horseID].Exp;
                int NeedNumber = Mathf.CeilToInt((float)NeedExp / HorseDanExp);
                if (number >= NeedNumber)
                {
                    IntList.Add(horseID);
                }
            }
        }
 
        foreach (var key in _DicHorse.Keys)//因为有成就任务限制所有 第一只坐骑红点逻辑特殊写
        {
            if (DicDefaultMount.ContainsKey(key) && DicDefaultMount[key] > _DicHorse[key].Lv
                && number > 0 && ASingleFeedRedPoint.ContainsKey(key))
            {
                ASingleFeedRedPoint[key].state = RedPointState.Simple;
                return;
            }
        }
        int GetMinLV = 100;
        int GetMountID = 0;
        List<int> IntListSkill = new List<int>();
        for (int j = 0; j < SortMount.Count; j++)//选取出可升级坐骑等级最低且有未激活技能的坐骑切经验最少
        {
            int Id = SortMount[j].HorseID;
            int GetHorseMaxLv = GetMountSkillMaxLV(Id);
            if (IntList.Contains(Id) && _DicHorse.ContainsKey(Id))
            {
                if (_DicHorse[Id].Lv < GetHorseMaxLv)
                {
                    IntListSkill.Add(Id);
                }
            }
        }
        int SkillHorseId = GetRedPointMountID(IntListSkill);
        if (SkillHorseId != 0 && ASingleFeedRedPoint.ContainsKey(SkillHorseId))
        {
            ASingleFeedRedPoint[SkillHorseId].state = RedPointState.Simple;
            return;
        }
 
 
        for (int j = 0; j < SortMount.Count; j++)//选取出可升级坐骑等级最低
        {
            int Id = SortMount[j].HorseID;
            if (IntList.Contains(Id) && _DicHorse.ContainsKey(Id))
            {
                if (_DicHorse[Id].Lv < GetMinLV)
                {
                    GetMinLV = _DicHorse[Id].Lv;
                    GetMountID = Id;
                }
            }
        }
        if (GetMountID != 0 && ASingleFeedRedPoint.ContainsKey(GetMountID))
        {
            ASingleFeedRedPoint[GetMountID].state = RedPointState.Simple;
            return;
        }
    }
 
    public int GetMinExpMount()
    {
        foreach (var key in ASingleFeedRedPoint.Keys)//当存在驯养红点时选中当有红点的那只
        {
            if (ASingleFeedRedPoint[key].state == RedPointState.Simple)
            {
                return key;
            }
        }
        int GetMountID = 0;
        int MountLV = 999;
        List<int> IntListSkill = new List<int>();
        foreach (var key in _DicHorse.Keys)
        {
            var mountConfig = HorseConfig.Get(key);
            if (_DicHorse[key].Lv < mountConfig.MaxLV)
            {
                IntListSkill.Add(key);
            }
        }
        int SkillHorseId = GetRedPointMountID(IntListSkill);
        if (SkillHorseId != 0)
        {
            GetMountID = SkillHorseId;
            return GetMountID;
        }
        foreach (var key in _DicHorse.Keys)//无红点时跳转选中最低阶数且未满级
        {
            var mountConfig = HorseConfig.Get(key);
            if (_DicHorse[key].Lv < MountLV && _DicHorse[key].Lv < mountConfig.MaxLV)
            {
                GetMountID = key;
                MountLV = _DicHorse[key].Lv;
            }
        }
        return GetMountID;
    }
 
    private int GetRedPointMountID(List<int> MountList)
    {
        int GetSkillMinLv = 999;
        for (int i = 0; i < MountList.Count; i++)
        {
            int SkillminLv = GetSkillLvDis(MountList[i]);
            if (SkillminLv < GetSkillMinLv && SkillminLv != 0)
            {
                GetSkillMinLv = SkillminLv;
            }
        }
 
        int mountId = 0;
        int ExpNumber = 999999999;
        for (int i = 0; i < MountList.Count; i++)
        {
            int SkillLv = GetSkillLvDis(MountList[i]);
            if (SkillLv > GetSkillMinLv || SkillLv == 0)
            {
                continue;
            }
            var Hor1 = HorseUpConfig.GetHorseIDAndLV(MountList[i], SkillLv);
            var Hor2 = HorseUpConfig.GetHorseIDAndLV(MountList[i], _DicHorse[(MountList[i])].Lv);
            int Exp = Hor1.NeedExpTotal - Hor2.NeedExpTotal - _DicHorse[(MountList[i])].Exp;
            if (Exp < ExpNumber)
            {
                ExpNumber = Exp;
                mountId = MountList[i];
            }
        }
        return mountId;
    }
 
    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(_HorseIDNow);
                    }
                }
            }
        }
 
        MountDanRed();
        MountStoneRed();
    }
 
    public void MountHA301(HA301_tagTrainHorseData info)//已拥有的坐骑(获得与刷新)
    {
        for (int i = 0; i < info.Num; i++)
        {
 
            if (_DicHorse.ContainsKey((int)info.InfoList[i].HorseID))
            {
                if ((int)info.InfoList[i].LV > _DicHorse[(int)info.InfoList[i].HorseID].Lv)
                {
                    if (OnMountUieffectUpLv != null && IsOk)
                    {
                        OnMountUieffectUpLv();
                    }
                }
                _DicHorse[(int)info.InfoList[i].HorseID].Lv = (int)info.InfoList[i].LV;//坐骑等级
                _DicHorse[(int)info.InfoList[i].HorseID].Exp = (int)info.InfoList[i].Exp;//坐骑经验
                if (Event_MountHA301U != null && IsOk)
                {
                    Event_MountHA301U((int)info.InfoList[i].HorseID);
                }
 
            }
            else
            {
                HorseClass _horseClass = new HorseClass();
                _horseClass.Lv = (int)info.InfoList[i].LV;//坐骑等级
                _horseClass.Exp = (int)info.InfoList[i].Exp;//坐骑经验
 
                _DicHorse.Add((int)info.InfoList[i].HorseID, _horseClass);
                if (Event_MountHA301A != null && IsOk)
                {
                    Event_MountHA301A((int)info.InfoList[i].HorseID);
                }
 
 
                if (IsOk && (int)info.InfoList[i].HorseID == autoActiveHorseId)
                {
                    var config = HorseConfig.Get(autoActiveHorseId);
                    if (_horseClass.Lv >= config.UseNeedRank)
                    {
                        AppearanceSwitch(autoActiveHorseId);
                        DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
                    }
                }
            }
        }
        MountStoneRed();
        MountChangeRedPoint();
        MountDanRed();
    }
 
    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;//攻击
            foreach (int key in _DicHorse.Keys)
            {
                HorseUpConfig tagMode = HorseUpConfig.GetHorseIDAndLV(key, _DicHorse[key].Lv);
                int[] intAttrValue = tagMode.AttrValue;
                if (intAttrValue.Length != 0)
                {
                    _AttT += intAttrValue[1];
                }
            }
            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;
        }
    }
 
    public void AppearanceSwitch(int HorseID)//坐骑外观切换
    {
        CA502_tagPlayerChooseHorse _tagCA502 = new CA502_tagPlayerChooseHorse();
        _tagCA502.Index = (uint)HorseID;
        GameNetSystem.Instance.SendInfo(_tagCA502);
    }
 
    public void MountDanUse(int HorseID, int Number, bool IsAutoBuy = false)//是否自动购买
    {
        CA527_tagCMHorseUp _tagC527 = new CA527_tagCMHorseUp();//向服务端发包坐骑经验单
        _tagC527.HorseID = (uint)HorseID;
        _tagC527.UseItemCnt = (byte)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>();
        HorseConfig horseConfig = HorseConfig.Get(mountCode);
        mountAttrDict.Clear();
        if (horseConfig == null) return mountAttrDict;
 
        int maxRank = horseConfig.MaxLV;
        HorseUpConfig cost = HorseUpConfig.GetHorseIDAndLV(mountCode, maxRank);
        if (cost != null)
        {
            int[] attrIds = cost.AttrType;
            int[] attrValues = cost.AttrValue;
            if (attrIds != null)
            {
                for (int j = 0; j < attrIds.Length; j++)
                {
                    if (!mountAttrDict.ContainsKey(attrIds[j]))
                    {
                        mountAttrDict.Add(attrIds[j], attrValues[j]);
                    }
                    else
                    {
                        mountAttrDict[attrIds[j]] += attrValues[j];
                    }
                }
            }
        }
        return mountAttrDict;
    }
 
    #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
}