少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
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
using LitJson;
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class AutoCutTreeModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
{
    public readonly int ToggleCount = 8;                //有多少个Toggle按钮
    public bool isTogDemonPowerUpStop = false;          //是否选中 装备妖力提升时停止
    public bool isTogAnd = false;                       //是否选中 和
    public bool isTogOr = false;                        //是否选中 或
    public bool isTogAttributeFilter1 = false;     //是否选中 第一列属性
    public bool isTogAttributeFilter2 = false;     //是否选中 第二列属性
    public bool isTogChallengeFullStop = false;         //是否选中 挑战状满停止
    public bool isTogHammerAcceleration = false;        //是否选中 锤炼加速
    public bool isTogConsumeStrength = false;           //是否选中 锤炼消耗体力
 
    public readonly int DropdownCount = 6;              //有多少个Dropdown下拉框
    public int dropEquipmentQuality = 0;                //选中状态值 装备品质
    public int dropAttributeAttack1 = 0;                //选中状态值 属性攻1
    public int dropAttributeDefend1 = 0;                //选中状态值 属性防1
    public int dropAttributeAttack2 = 0;                //选中状态值 属性攻2
    public int dropAttributeDefend2 = 0;                //选中状态值 属性防1
    public int dropStrength = 0;                        //选中状态值 消耗体力
 
    public List<Dropdown.OptionData> dropEquipmentQualityOptionList = new List<Dropdown.OptionData>();
    public List<Dropdown.OptionData> dropAttributeOptionAttackList = new List<Dropdown.OptionData>();
    public List<Dropdown.OptionData> dropAttributeOptionDefendList = new List<Dropdown.OptionData>();
    public List<Dropdown.OptionData> dropStrengthOptionList = new List<Dropdown.OptionData>();
 
    string markStr = "AutoCutTree_";
 
    int toggleCount = 8;                        //toggle个数
    int dropdownCount = 6;                      //dropdown个数
    int[] countCorrespondLVArr;                 //单次最大可砍树次数对应所需仙树等级列表   
    List<int> itemColorList;
 
    private int m_autoCutTreeState = 0;//0 未开启 1 处理装备 2 发砍树包 3 发装备包 4 展示装备详情 4 等砍树包 5 等装备包 6 等玩家操作 //0 未开启 1 处理中 2 等待中
    public int autoCutTreeState
    {
        get
        {
            return m_autoCutTreeState;
        }
        set
        {
            m_autoCutTreeState = value;
            DebugEx.Log("m_autoCutTreeState: " + m_autoCutTreeState);
 
        }
    }
    public bool isAutoCutTree { get { return m_autoCutTreeState != 0; } }
    public bool isPause;
    public bool isDecomposeCheck { get { return LocalSave.GetBool("floorEDecomp" + PlayerDatas.Instance.baseData.PlayerID); } }     //是否勾选替换后自动分解原装备
    public bool isWaitPlayer = false;
 
    public event Action UpdateInfo;
    public event Action AutoCutTreeStartEvent;                           //自动砍树开启事件
    public event Action AutoCutTreeStopEvent;                            //自动砍树停止事件
    CutTreeModel cutTreeModel { get { return ModelCenter.Instance.GetModel<CutTreeModel>(); } }
    PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
    EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
    MonthWeekInvestModel monthWeekInvestModel { get { return ModelCenter.Instance.GetModel<MonthWeekInvestModel>(); } }
 
    public override void Init()
    {
        AutoCutTreeTime.Instance.TimedEvent += OnTimedEvent;
        countCorrespondLVArr = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("CutTree").Numerical2);
        itemColorList = EquipColorPlaceConfig.GetItemColorList();
    }
 
    public void OnBeforePlayerDataInitialize()
    {
        autoCutTreeState = 0;
        ClearAll();
        InitDropdownInfo();
    }
 
    public void OnPlayerLoginOk()
    {
        LoadPlayerDropdownConfig();
        LoadPlayerToggleConfig();
    }
 
    public override void UnInit()
    {
        AutoCutTreeTime.Instance.TimedEvent -= OnTimedEvent;
    }
 
    private void OnTimedEvent()
    {
        //处于停止状态,不进入处理流程
        if (!isAutoCutTree)
            return;
        //暂停中
        if (isPause)
            return;
        //0 未开启 1 判断 2 自动发砍树包 3 等待砍树包 4 自动发装备销毁包 5 等自动销毁包  6 展示装备详情 7 等待玩家操作 
        if (autoCutTreeState == 1)
        {
            if (IsEquipOnFloorEmpty())
            {
                //发砍树包
                autoCutTreeState = 2;
            }
            else
            {
                //存在能销毁的
                if (IsDestroyEquip())
                {
                    //发销毁包
                    autoCutTreeState = 4;
                }
                else
                {
                    //展示
                    autoCutTreeState = 6;
                }
            }
        }
        else if (autoCutTreeState == 2)
        {
            //没桃子
            if (UIHelper.GetMoneyCnt(41) < 1)
            {
                SysNotifyMgr.Instance.ShowTip("LackMoneyCommon", 41);
                StopAutoCutTree();
                return;
            }
            //当勾选了挑战状满时停止 且 竞技场可挑战次数等于最大次数时
            if (isTogChallengeFullStop && ArenaModel.Instance.playerInfo.DayPKCount >= ArenaModel.Instance.freeMaxMatchNum)
            {
                SysNotifyMgr.Instance.ShowTip("AutoCutTree02");
                StopAutoCutTree();
                return;
            }
            SendAutoCutTree();
            autoCutTreeState = 3;
        }
        else if (autoCutTreeState == 3)
        {
            //处于等待砍树包状态
            if (cutTreeModel.waitCutTreePack)
                return;
            //在播放砍树动画中
            if (cutTreeModel.isPlayCutTreeAnim)
                return;
            autoCutTreeState = 1;
        }
        else if (autoCutTreeState == 4)
        {
            List<byte> list = new List<byte>();
            var items = packModel.GetItems(PackType.EquipOnFloor);
            for (int i = 0; i < items.Count; i++)
            {
                var equip = items[i];
                if (equip == null)
                    continue;
#if UNITY_EDITOR
                OutEquipInfo(equip);
#endif
                //记录不符合条件的装备
                if (!IsFilteredEquipment(equip))
                {
                    list.Add((byte)equip.gridIndex);
                }
            }
            cutTreeModel.SendCutTreeEquipOP(list.ToArray(), 2);
            list.Clear();
            list = null;
            autoCutTreeState = 5;
        }
        else if (autoCutTreeState == 5)
        {
            //处于等待销毁/装备包状态
            if (cutTreeModel.waitEquipOPPack)
                return;
            //没勾选替换后自动分解装备 只要地板有装备就展示
            if (!isDecomposeCheck)
            {
                autoCutTreeState = 6;
            }
            else
            {
                autoCutTreeState = 1;
            }
        }
        else if (autoCutTreeState == 6)
        {
            //装备详情页展示中
            if (WindowCenter.Instance.IsOpen<EquipExchangeWin>())
                return;
            if (!IsEquipOnFloorEmpty())
            {
                //有物品可展示就展示
                cutTreeModel.OpenEquipExchangeWin(packModel.GetItems(PackType.EquipOnFloor)[0]);
                isWaitPlayer = true;
                autoCutTreeState = 7;
            }
            else
            {
                //没有可展示的就回到判断
                autoCutTreeState = 1;
            }
        }
        else if (autoCutTreeState == 7)
        {
            //玩家没有点击分解/替换
            if (isWaitPlayer)
                return;
            autoCutTreeState = 5;
        }
    }
 
    //没有掉落装备
    bool IsEquipOnFloorEmpty()
    {
        bool isEmpty = false;
        var items = packModel.GetItems(PackType.EquipOnFloor);
        if (items.IsNullOrEmpty())
            isEmpty = true;
        items.Clear();
        items = null;
        return isEmpty;
    }
 
    //是否有符合销毁条件的装备
    bool IsDestroyEquip()
    {
        var items = packModel.GetItems(PackType.EquipOnFloor);
        List<byte> list = new List<byte>();
        for (int i = 0; i < items.Count; i++)
        {
            if (!IsFilteredEquipment(items[i]))
                return true;
        }
        return false;
 
    }
 
 
    //输出装备详情
    void OutEquipInfo(ItemModel equip)
    {
        var time = TimeUtility.ServerNow.ToLongTimeString();
        List<int> equipAttr3 = equipModel.GetEquipFightAttrs(equip);
        List<string> equipStr3 = new List<string>();
        if (!equipAttr3.IsNullOrEmpty())
        {
            for (int i = 0; i < equipAttr3.Count; i++)
            {
                equipStr3.Add(PlayerPropertyConfig.Get(equipAttr3[i]).Name);
            }
        }
        DebugEx.Log($"时间: {time} 装备名称 {equip.config.ItemName} 该装备上的战斗属性(为空没有战斗属性) {string.Join(" ", equipStr3)} 该装备战力 {EquipFightPower.Instance.GetFightPowerBuyScore(equip.score)} 身上对应位置装备战力(没装备是0) {CurrentGearFightPower(equip)} 处理结果(ture 展示 false 发销毁包) {IsFilteredEquipment(equip)} 勾选状态 装备妖力提升时停止 {isTogDemonPowerUpStop} 攻1 {isTogAnd} 防1 {isTogOr} 攻2 {isTogAttributeFilter1} 防2 {isTogAttributeFilter2} 挑战状满时停止 {isTogChallengeFullStop} 锤炼加速 {isTogHammerAcceleration} 锤炼消耗体力 {isTogConsumeStrength} 下拉框状态 装备品质 {Language.Get("AutoCutTree13", Language.Get("Item_Text_" + (dropEquipmentQuality + 1)))} 攻1 {GetPlayerCombatAttributesName(2, dropAttributeAttack1)} 防1 {GetPlayerCombatAttributesName(3, dropAttributeDefend1)} 攻2 {GetPlayerCombatAttributesName(2, dropAttributeAttack2)} 防2 {GetPlayerCombatAttributesName(3, dropAttributeDefend2)} 消耗体力 {dropStrength + 1}");
    }
 
    //获取当前身上装备的评分
    int CurrentGearFightPower(ItemModel newEquip)
    {
        ItemModel oldEquip = GetCurrentEquippedGear(newEquip);
        int oldScore = oldEquip == null ? 0 : oldEquip.score;
        return EquipFightPower.Instance.GetFightPowerBuyScore(oldScore);
    }
 
    //获取玩家设定的战斗属性状况
    string GetPlayerCombatAttributesName(int type, int value)
    {
        if (value == 0)
        {
            return Language.Get("AutoCutTree11");
        }
        else
        {
            Dictionary<int, List<int>> PropertyIDDict = PlayerPropertyConfig.GetShowDict();
            return PlayerPropertyConfig.Get(PropertyIDDict[type][Mathf.Max(value - 1, 0)]).Name;
        }
    }
 
    //开始自动砍树
    public void StartAutoCutTree()
    {
        //没桃子
        if (UIHelper.GetMoneyCnt(41) < 1)
        {
            SysNotifyMgr.Instance.ShowTip("LackMoneyCommon", 41);
            StopAutoCutTree();
            return;
        }
        //当勾选了挑战状满时停止 且 竞技场可挑战次数等于最大次数时
        if (isTogChallengeFullStop && ArenaModel.Instance.playerInfo.DayPKCount >= ArenaModel.Instance.freeMaxMatchNum)
        {
            SysNotifyMgr.Instance.ShowTip("AutoCutTree02");
            StopAutoCutTree();
            return;
        }
        //勾选了锤炼加速 且 购买了月卡
        if (isTogHammerAcceleration && IsBuyMonthWeekInvest())
        {
            StartSpeedCutTree();
        }
        if (WindowCenter.Instance.IsOpen<AutoCutTreeWin>())
            WindowCenter.Instance.Close<AutoCutTreeWin>();
        isPause = false;
        cutTreeModel.waitCutTreePack = false;
        autoCutTreeState = 1;
        AutoCutTreeStartEvent?.Invoke();
    }
 
    //停止自动砍树
    public void StopAutoCutTree()
    {
        isPause = false;
        CloseSpeedCutTree();
        autoCutTreeState = 0;
        AutoCutTreeStopEvent?.Invoke();
    }
 
    //继续自动砍树
    public void ContinueAutoCutTree()
    {
        isPause = false;
    }
 
    //暂停自动砍树
    public void PauseAutoCutTree()
    {
        isPause = true;
    }
 
    //暂停自动砍树 表现为暂停对地板物品的处理 timeS暂停几秒
    public void PauseAutoCutTree(float timeS, Action action = null)
    {
        isPause = true;
        Clock.AlarmAfter(timeS, () =>
        {
            isPause = false;
            action?.Invoke();
        });
    }
 
    //开启锤炼加速
    public void StartSpeedCutTree()
    {
        cutTreeModel.cutTreeSpeed = 2;
    }
 
    //关闭锤炼加速
    public void CloseSpeedCutTree()
    {
        cutTreeModel.cutTreeSpeed = 1;
    }
 
    //是否购买了月卡
    public bool IsBuyMonthWeekInvest()
    {
        monthWeekInvestModel.selectType = 8;
        return monthWeekInvestModel.IsInvested(monthWeekInvestModel.selectType);
    }
 
    //自动砍树发包
    public void SendAutoCutTree()
    {
        cutTreeModel.waitCutTreePack = true;
        UI3DModelExhibition.InstanceTree.ChangeModelEulerAngles(new Vector3(0, PlayerModelMarkConfig.Get(PlayerDatas.Instance.baseData.modelMark).angel, 0));
        cutTreeModel.SendCutTree(isTogConsumeStrength ? dropStrength + 1 : 1);
    }
 
    //获取当前装备对应的身上装备
    ItemModel GetCurrentEquippedGear(ItemModel equip)
    {
        var equipGuid = equipModel.GetEquip(new Int2(PlayerDatas.Instance.baseData.suitLevel, equip.config.EquipPlace));
        if (string.IsNullOrEmpty(equipGuid))
            return null;
        return packModel.GetItemByGuid(equipGuid);
    }
 
    //是否当前装备比身上装备战力高
    public bool IsCurrentGearStronger(ItemModel newEquip)
    {
        ItemModel oldEquip = GetCurrentEquippedGear(newEquip);
        int oldScore = oldEquip == null ? 0 : oldEquip.score;
        int showFightPower = EquipFightPower.Instance.GetFightPowerBuyScore(newEquip.score - oldScore);
        if (showFightPower <= 0)
            return false;
        return true;
    }
 
    //是否当前装备属性和设置属性匹配
    //state 3 对应toggle[3]开启 比较 Dropdown[1](属性攻1) 和 Dropdown[2](属性防1)
    //state 4 对应toggle[4]开启 比较 Dropdown[3](属性攻2) 和 Dropdown[4](属性防2)
    bool IsCurrentGearAttributes(int state, ItemModel equip)
    {
 
        Dictionary<int, List<int>> PropertyIDDict = PlayerPropertyConfig.GetShowDict();
        List<int> equipAttr3 = equipModel.GetEquipFightAttrs(equip);
        if (equipAttr3.IsNullOrEmpty())
            return false;
        int value1 = state == 3 ? dropAttributeAttack1 - 1 : dropAttributeDefend1 - 1;
        int value2 = state == 3 ? dropAttributeAttack2 - 1 : dropAttributeDefend2 - 1;
        int attr1 = PropertyIDDict[2][Mathf.Max(value1, 0)];
        int attr2 = PropertyIDDict[3][Mathf.Max(value2, 0)];
        bool isDropdown1 = false;
        bool isDropdown2 = false;
        if (value1 == -1)
            isDropdown1 = true;
        if (value2 == -1)
            isDropdown2 = true;
        for (int i = 0; i < equipAttr3.Count; i++)
        {
            if (value1 > -1 && equipAttr3[i] == attr1)
                isDropdown1 = true;
            if (value2 > -1 && equipAttr3[i] == attr2)
                isDropdown2 = true;
        }
        if (isDropdown1 && isDropdown2)
            return true;
        return false;
    }
 
    //两对属性有一对是匹配的 
    bool isAllAttributesCurrent(ItemModel equip)
    {
        bool isAttributes1 = IsCurrentGearAttributes(3, equip);
        bool isAttributes2 = IsCurrentGearAttributes(4, equip);
        if (isAttributes1 || isAttributes2)
            return true;
        return false;
    }
 
    //装备符合筛选条件
    public bool IsFilteredEquipment(ItemModel equip)
    {
        //装备品质不够
        if (equip.config.ItemColor < dropEquipmentQuality + 1)
            return false;
 
        if (isTogDemonPowerUpStop && !isTogAttributeFilter1 && !isTogAttributeFilter2)
        {
            //战力没提升
            if (!IsCurrentGearStronger(equip))
                return false;
            return true;
        }
        else if (isTogDemonPowerUpStop && isTogAttributeFilter1 && !isTogAttributeFilter2)
        {
            //勾选了和
            if (isTogAnd)
            {
                //战力没提升
                if (!IsCurrentGearStronger(equip))
                    return false;
                //两个属性有一个对不上
                if (!IsCurrentGearAttributes(3, equip))
                    return false;
                return true;
            }
            //勾选了或
            else
            {
                //战力没提升
                if (!IsCurrentGearStronger(equip))
                {
                    //两个属性有一个对不上
                    if (!IsCurrentGearAttributes(3, equip))
                        return false;
                    return true;
                }
                else
                {
                    return true;
                }
            }
        }
        else if (isTogDemonPowerUpStop && !isTogAttributeFilter1 && isTogAttributeFilter2)
        {
            //勾选了和
            if (isTogAnd)
            {
                //战力没提升
                if (!IsCurrentGearStronger(equip))
                    return false;
                //两个属性有一个对不上
                if (!IsCurrentGearAttributes(4, equip))
                    return false;
                return true;
            }
            //勾选了或
            else
            {
                //战力没提升
                if (!IsCurrentGearStronger(equip))
                {
                    //两个属性有一个对不上
                    if (!IsCurrentGearAttributes(4, equip))
                        return false;
                    return true;
                }
                else
                {
                    return true;
                }
            }
        }
        else if (isTogDemonPowerUpStop && isTogAttributeFilter1 && isTogAttributeFilter2)
        {
            //勾选了和
            if (isTogAnd)
            {
                //战力没提升
                if (!IsCurrentGearStronger(equip))
                    return false;
                bool isAttributes1 = IsCurrentGearAttributes(3, equip);
                bool isAttributes2 = IsCurrentGearAttributes(4, equip);
                if (isAttributes1 || isAttributes2)
                    return true;
                return false;
            }
            //勾选了或
            else
            {
                //战力没提升
                if (!IsCurrentGearStronger(equip))
                {
                    //两对属性都不匹配 
                    if (!isAllAttributesCurrent(equip))
                        return false;
                    return true;
                }
                else
                {
                    return true;
                }
            }
        }
        else if (!isTogDemonPowerUpStop && isTogAttributeFilter1 && !isTogAttributeFilter2)
        {
            //两个属性有一个对不上
            if (!IsCurrentGearAttributes(3, equip))
                return false;
            return true;
        }
        else if (!isTogDemonPowerUpStop && !isTogAttributeFilter1 && isTogAttributeFilter2)
        {
            //两个属性有一个对不上
            if (!IsCurrentGearAttributes(4, equip))
                return false;
            return true;
        }
        else if (!isTogDemonPowerUpStop && isTogAttributeFilter1 && isTogAttributeFilter2)
        {
            //四个战斗属性都不匹配
            if (!isAllAttributesCurrent(equip))
                return false;
            return true;
        }
        else
        {
            return true;
        }
    }
 
    //更改Toggle:装备妖力提升时停止
    public void ChangeToggleDemonPowerUpStop(bool isOn)
    {
        //没有开启或关闭的限制条件 直接更改
        isTogDemonPowerUpStop = isOn;
        //两对战斗属性中有一对属性被勾选时
        if (isTogAttributeFilter1 || isTogAttributeFilter2)
        {
            //开启时,把和勾上.关闭时,去掉和的勾
            isTogAnd = isOn;
            isTogOr = false;
        }
        SavePlayerToggleConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Toggle:和
    public void ChangeToggleAnd(bool isOn)
    {
        //isOn==false 试图取消勾选时直接勾上 
        //isOn==true 判断 装备妖力提升时停止 和 两对战斗属性中有一对属性被勾选时 才能被勾选
        isTogAnd = isOn ? isTogDemonPowerUpStop && (isTogAttributeFilter1 || isTogAttributeFilter2) : true;
        isTogOr = false;
        SavePlayerToggleConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Toggle:或
    public void ChangeToggleOr(bool isOn)
    {
        //isOn==false 试图取消勾选时直接勾上 
        //isOn==true 判断 装备妖力提升时停止 和 两对战斗属性中有一对属性被勾选时 才能被勾选
        isTogAnd = false;
        isTogOr = isOn ? isTogDemonPowerUpStop && (isTogAttributeFilter1 || isTogAttributeFilter2) : true;
        SavePlayerToggleConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Toggle:第一列战斗属性
    public void ChangeToggleAttributeFilter1(bool isOn)
    {
        //没有开启或关闭的限制条件 直接更改
        isTogAttributeFilter1 = isOn;
        //勾选时
        if (isOn)
        {
            //没勾选装备妖力提升时停止 和,或两个选项取消勾选
            if (!isTogDemonPowerUpStop)
            {
                isTogAnd = false;
                isTogOr = false;
            }
            else
            {
                //勾选了装备妖力提升时停止 和 第二对战斗属性没有被勾选 勾上和选项
                if (!isTogAttributeFilter2)
                {
                    isTogAnd = true;
                    isTogOr = false;
                }
            }
        }
        //取消勾选时
        else
        {
            //第二对战斗属性没有被勾选 和,或两个选项取消勾选
            if (!isTogAttributeFilter2)
            {
                isTogAnd = false;
                isTogOr = false;
            }
        }
        SavePlayerToggleConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Toggle:第二列战斗属性
    public void ChangeToggleAttributeFilter2(bool isOn)
    {
        //没有开启或关闭的限制条件 直接更改
        isTogAttributeFilter2 = isOn;
        //勾选时
        if (isOn)
        {
            //没勾选装备妖力提升时停止 和,或两个选项取消勾选
            if (!isTogDemonPowerUpStop)
            {
                isTogAnd = false;
                isTogOr = false;
            }
            else
            {
                //勾选了装备妖力提升时停止 和 第二对战斗属性没有被勾选 勾上和选项
                if (!isTogAttributeFilter1)
                {
                    isTogAnd = true;
                    isTogOr = false;
                }
            }
        }
        //取消勾选时
        else
        {
            //第一对战斗属性没有被勾选 和,或两个选项取消勾选
            if (!isTogAttributeFilter1)
            {
                isTogAnd = false;
                isTogOr = false;
            }
        }
        SavePlayerToggleConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Toggle:挑战状满停止
    public void ChangeToggleChallengeFullStop(bool isOn)
    {
        //没有开启或关闭的限制条件 直接更改
        isTogChallengeFullStop = isOn;
        SavePlayerToggleConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Toggle:锤炼加速
    public void ChangeToggleHammerAcceleration(bool isOn)
    {
        //没买月卡就跳转到月卡界面
        if (!IsBuyMonthWeekInvest())
        {
            WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.MonthInvest);
            isTogHammerAcceleration = false;
        }
        else
        {
            if (isOn)
            {
                StartSpeedCutTree();
            }
            else
            {
                CloseSpeedCutTree();
            }
 
            isTogHammerAcceleration = isOn;
        }
        SavePlayerToggleConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Toggle:消耗体力
    public void ChangeToggleConsumeStrength(bool isOn)
    {
        //没有开启或关闭的限制条件 直接更改
        isTogConsumeStrength = isOn;
        SavePlayerToggleConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Dropdown:装备品质
    public void ChangeDropdownEquipmentQuality(int value)
    {
        dropEquipmentQuality = value;
        SavePlayerDropdownConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Dropdown:属性攻1
    public void ChangeDropdownAttributeAttack1(int value)
    {
        dropAttributeAttack1 = value;
        SavePlayerDropdownConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Dropdown:属性防1
    public void ChangeDropdownAttributeDefend1(int value)
    {
        dropAttributeDefend1 = value;
        SavePlayerDropdownConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Dropdown:属性攻2
    public void ChangeDropdownAttributeAttack2(int value)
    {
        dropAttributeAttack2 = value;
        SavePlayerDropdownConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Dropdown:属性防2
    public void ChangeDropdownAttributeDefend2(int value)
    {
        dropAttributeDefend2 = value;
        SavePlayerDropdownConfig();
        UpdateInfo?.Invoke();
    }
 
    //更改Dropdown:消耗体力
    public void ChangeDropdownStrength(int value)
    {
        //当前的仙树等级低于所需的仙树等级
        if (cutTreeModel.GetTreeLV() < countCorrespondLVArr[value])
        {
            SysNotifyMgr.Instance.ShowTip("AutoCutTree01", countCorrespondLVArr[value]);
            return;
        }
        dropStrength = value;
        SavePlayerDropdownConfig();
        UpdateInfo?.Invoke();
    }
 
    void ClearAll()
    {
        dropEquipmentQualityOptionList.Clear();
        dropAttributeOptionAttackList.Clear();
        dropAttributeOptionDefendList.Clear();
        dropStrengthOptionList.Clear();
    }
 
    //初始化Dropdown选项内容 
    void InitDropdownInfo()
    {
        for (int i = 0; i < itemColorList.Count; i++)
        {
            int itemColor = itemColorList[i];
            string itemColorInfo = Language.Get("AutoCutTree13", Language.Get("Item_Text_" + itemColor));
            string itemColorStr = UIHelper.AppendColor(itemColor, itemColorInfo);
            dropEquipmentQualityOptionList.Add(new Dropdown.OptionData(itemColorStr));
        }
        //在战斗属性(攻)和战斗时属性(防)之前插入属性"任意"
        dropAttributeOptionAttackList.Add(new Dropdown.OptionData(Language.Get("AutoCutTree11")));
        dropAttributeOptionDefendList.Add(new Dropdown.OptionData(Language.Get("AutoCutTree11")));
        Dictionary<int, List<int>> PropertyIDDict = PlayerPropertyConfig.GetShowDict();
        for (int i = 0; i < PropertyIDDict[2].Count; i++)
        {
            string name = PlayerPropertyConfig.Get(PropertyIDDict[2][i]).Name;
            dropAttributeOptionAttackList.Add(new Dropdown.OptionData(name));
        }
        for (int i = 0; i < PropertyIDDict[3].Count; i++)
        {
            string name = PlayerPropertyConfig.Get(PropertyIDDict[3][i]).Name;
            dropAttributeOptionDefendList.Add(new Dropdown.OptionData(name));
        }
        for (int i = 0; i < countCorrespondLVArr.Length; i++)
        {
            dropStrengthOptionList.Add(new Dropdown.OptionData((i + 1).ToString()));
        }
    }
 
    //获取本地存储的Toggle的key
    string GetLocalToggleKey()
    {
        return StringUtility.Contact(markStr, "Toggle_", PlayerDatas.Instance.baseData.PlayerID);
    }
 
    //获取本地存储的Dropdown的key
    string GetLocalDropdownKey()
    {
        return StringUtility.Contact(markStr, "Dropdown_", PlayerDatas.Instance.baseData.PlayerID);
    }
 
    //确保读取到的值是合法的
    int GetDropdownSafeValue(List<Dropdown.OptionData> list, int value)
    {
        if (value <= 0)
            return 0;
        if (value > list.Count - 1)
            return 0;
        return value;
    }
 
    //读取Dropdown的选中情况
    void LoadPlayerDropdownConfig()
    {
        int[] tempArr = LocalSave.GetIntArray(GetLocalDropdownKey());
        //本地读取的数量对不上
        if (tempArr == null || tempArr.Length != dropdownCount)
            return;
        dropEquipmentQuality = GetDropdownSafeValue(dropEquipmentQualityOptionList, tempArr[0]);
        dropAttributeAttack1 = GetDropdownSafeValue(dropAttributeOptionAttackList, tempArr[1]);
        dropAttributeDefend1 = GetDropdownSafeValue(dropAttributeOptionAttackList, tempArr[2]);
        dropAttributeAttack2 = GetDropdownSafeValue(dropAttributeOptionDefendList, tempArr[3]);
        dropAttributeDefend2 = GetDropdownSafeValue(dropAttributeOptionDefendList, tempArr[4]);
        dropStrength = GetDropdownSafeValue(dropStrengthOptionList, tempArr[5]);
    }
 
    //保存Dropdown的选中情况
    void SavePlayerDropdownConfig()
    {
        int[] tempArr = new int[]
        {
            dropEquipmentQuality,
            dropAttributeAttack1,
            dropAttributeDefend1,
            dropAttributeAttack2,
            dropAttributeDefend2,
            dropStrength
        };
        LocalSave.SetIntArray(GetLocalDropdownKey(), tempArr);
    }
 
    //是1输出true,否则输出false
    bool GetIntToBool(int num)
    {
        return num == 1;
    }
 
    //读取Toggle的选中情况
    void LoadPlayerToggleConfig()
    {
        int[] tempArr = LocalSave.GetIntArray(GetLocalToggleKey());
        //本地读取的数量对不上
        if (tempArr == null || tempArr.Length != ToggleCount)
            return;
        isTogDemonPowerUpStop = GetIntToBool(tempArr[0]);
        isTogAnd = GetIntToBool(tempArr[1]);
        isTogOr = GetIntToBool(tempArr[2]);
        isTogAttributeFilter1 = GetIntToBool(tempArr[3]);
        isTogAttributeFilter2 = GetIntToBool(tempArr[4]);
        isTogChallengeFullStop = GetIntToBool(tempArr[5]);
        isTogHammerAcceleration = GetIntToBool(tempArr[6]);
        isTogConsumeStrength = GetIntToBool(tempArr[7]);
    }
 
    //将bool类型的状态转化成1和0
    int GetBoolToInt(bool isOn)
    {
        return isOn ? 1 : 0;
    }
 
    //保存Toggle的选中情况
    void SavePlayerToggleConfig()
    {
        int[] tempArr = new int[]
        {
            GetBoolToInt(isTogDemonPowerUpStop),
            GetBoolToInt(isTogAnd),
            GetBoolToInt(isTogOr),
            GetBoolToInt(isTogAttributeFilter1),
            GetBoolToInt(isTogAttributeFilter2),
            GetBoolToInt(isTogChallengeFullStop),
            GetBoolToInt(isTogHammerAcceleration),
            GetBoolToInt(isTogConsumeStrength)
        };
        LocalSave.SetIntArray(GetLocalToggleKey(), tempArr);
    }
 
 
}