少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
namespace vnxbqy.UI
{
    public class RealmModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize
    {
        Dictionary<int, Dictionary<int, int>> m_RealmProperties = new Dictionary<int, Dictionary<int, int>>();
        Dictionary<int, Dictionary<int, int[]>> m_RealmPreviewEquips = new Dictionary<int, Dictionary<int, int[]>>();
        Dictionary<int, RealmLevelUpEquipCondition> m_RealmEquipConditions = new Dictionary<int, RealmLevelUpEquipCondition>();
        Dictionary<int, Dictionary<int, int[]>> m_RecommandEquips = new Dictionary<int, Dictionary<int, int[]>>();
        List<List<int>> m_RealmStages = new List<List<int>>();
        public int realmMaxLevel { get; private set; }
        public int realmPoolOpenLevel { get; private set; }
        public int realmEquipDisplayLevel { get; private set; }
        public int realmLevelUpReikiPoint { get; private set; }
        public bool isBossPass { get; private set; }
        public int xxzlAwardState { get; private set; }
        public int realmExpTime { get; private set; }
        public long startExp { get; private set; }
 
        public uint buffAddRate { get; private set; }
        public uint buffSeconds { get; private set; }
 
        public int realmUpgrateNoEnoughReason = 0;  //境界提升不足提示 1。换装备,2 升星
 
        public long totalExp
        {
            get
            {
                if (PlayerDatas.Instance.baseData.realmLevel < realmPoolOpenLevel)
                {
                    return startExp;
                }
 
                float exp = startExp;
 
                var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
                if (exp >= config.expLimit)
                {
                    return config.expLimit;
                }
 
                var tick = (TimeUtility.ServerNow - expStartTime).Ticks;
                var singleTick = realmExpTime * TimeSpan.TicksPerSecond;
                var times = tick / singleTick;
 
                float expRate = config.expRate;
 
                long buffTimes = 0;
                if (buffSeconds > 0)
                {
                    var buffTick = buffSeconds * TimeSpan.TicksPerSecond;
                    var buffTicks = tick > buffTick ? buffTick : tick;
                    buffTimes = buffTicks / singleTick;
                }
 
                if (buffTimes > 0)
                {
                    var rate = expRate + expRate * (buffAddRate / 10000f);
                    exp += rate * buffTimes;
                }
 
                var normalTimes = times - buffTimes;
                if (normalTimes > 0)
                {
                    exp += expRate * normalTimes;
                }
 
                exp = exp > config.expLimit ? config.expLimit : exp;
                return (long)exp;
            }
        }
 
        public DateTime expStartTime { get; private set; }
 
        int realmPoolRedpointPercent = 100;
 
        UIEffect realmEffect;
        int realmEffectCount = 0;
 
        public event Action OnTowerPassEvent;
        public int passedFloor;
        //可挑战层
        public int currentFloor {
            get { 
                return passedFloor + 1; 
            } 
        }
 
        public int selectFloorID;    //新的大境界未解锁,或者最后一层时,显示可选的最高层
 
        public const int REALM_DUNGEON_ID = 31110;
        public const int Tower_MapId = 31310;
 
        public readonly Redpoint levelUpRedpoint = new Redpoint(114, 11401);
        public readonly Redpoint challengeRedpoint = new Redpoint(114, 11402);
        //public readonly Redpoint realmPoolRedpoint = new Redpoint(114, 11403);
        public readonly Redpoint realmDailyRedpoint = new Redpoint(114, 11404);
        public readonly Redpoint xxzlRedpoint = new Redpoint(114, 11405);
        public readonly Redpoint towerRedpoint = new Redpoint(114, 11406);
 
        int m_SelectRealm = 0;
        public int selectRealm
        {
            get { return m_SelectRealm; }
            set
            {
                if (m_SelectRealm != value)
                {
                    m_SelectRealm = value;
                    if (selectRealmRefresh != null)
                    {
                        selectRealmRefresh();
                    }
                }
            }
        }
 
        int cacheMapId = 0;
 
        bool redpointDirty = false;
 
        bool serverInited = false;
 
        public List<int> displayRealms = new List<int>();
 
        public int displayRealmLevel
        {
            get
            {
                if (displayRealms.Count > 0)
                {
                    return displayRealms[0];
                }
                return PlayerDatas.Instance.baseData.realmLevel;
            }
        }
 
        public event Action selectRealmRefresh;
        public event Action realmExpRefresh;
        public event Action<bool> xxzlStateRefresh;
 
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
        EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        ActivitiesPushModel pushModel { get { return ModelCenter.Instance.GetModel<ActivitiesPushModel>(); } }
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
        DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
 
        public override void Init()
        {
            StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish;
            PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
            GlobalTimeEvent.Instance.secondEvent += PerSecond;
            packModel.refreshItemCountEvent += RefreshItemCountEvent;
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
            WindowCenter.Instance.windowBeforeOpenEvent += OnBeforeWindowOpen;
            ParseConfig();
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            isBossPass = false;
            expStartTime = DateTime.Now;
            startExp = 0;
            serverInited = false;
            buffSeconds = 0;
            buffAddRate = 0;
            realmEffectCount = 0;
            xxzlAwardState = 0;
            SysNotifyMgr.Instance.OnSystemNotifyEvent -= OnSystemNotifyEvent;
        }
 
        public void OnPlayerLoginOk()
        {
            redpointDirty = true;
            serverInited = true;
 
            SysNotifyMgr.Instance.OnSystemNotifyEvent -= OnSystemNotifyEvent;
            SysNotifyMgr.Instance.OnSystemNotifyEvent += OnSystemNotifyEvent;
 
            RefreshRedpoint();
            TryPushRealmPoolMessage();
        }
 
        public override void UnInit()
        {
            StageLoad.Instance.onStageLoadFinish -= OnStageLoadFinish;
            PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
            packModel.refreshItemCountEvent -= RefreshItemCountEvent;
            GlobalTimeEvent.Instance.secondEvent -= PerSecond;
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
        }
 
        private void OnFuncStateChangeEvent(int id)
        {
            if (id == (int)FuncOpenEnum.Realm)
            {
                RefreshRedpoint();
            }
        }
 
        private void PerSecond()
        {
            if (redpointDirty)
            {
                RefreshRedpoint();
                redpointDirty = false;
            }
            //if (serverInited)
            //{
            //    RefreshRealmPoolRedpoint();
            //}
 
            TryPlayRealmEffect();
        }
 
        void ParseConfig()
        {
            realmMaxLevel = 0;
            List<int> stages = new List<int>();
            m_RealmStages.Add(stages);
            var configs = RealmConfig.GetValues();
            foreach (var config in configs)
            {
                if (config.Lv > realmMaxLevel)
                {
                    realmMaxLevel = config.Lv;
                }
 
                if (config.AddAttrType != null && config.AddAttrType.Length > 0)
                {
                    Dictionary<int, int> dict = new Dictionary<int, int>();
                    for (int i = 0; i < config.AddAttrType.Length; i++)
                    {
                        dict.Add(config.AddAttrType[i], config.AddAttrNum[i]);
                    }
                    m_RealmProperties.Add(config.Lv, dict);
                }
 
                if (config.Lv != 0)
                {
                    stages.Add(config.Lv);
 
                    if (config.BossID != 0)
                    {
                        stages = new List<int>();
                        m_RealmStages.Add(stages);
                    }
                }
 
                if (!string.IsNullOrEmpty(config.equips))
                {
                    var json = LitJson.JsonMapper.ToObject(config.equips);
                    Dictionary<int, int[]> dict = new Dictionary<int, int[]>();
                    foreach (var jobKey in json.Keys)
                    {
                        var job = int.Parse(jobKey);
                        var equipArray = LitJson.JsonMapper.ToObject<int[]>(json[jobKey].ToJson());
                        dict.Add(job, equipArray);
                    }
                    m_RealmPreviewEquips.Add(config.Lv, dict);
                }
 
                if (!string.IsNullOrEmpty(config.recommandEquips))
                {
                    var json = LitJson.JsonMapper.ToObject(config.recommandEquips);
                    Dictionary<int, int[]> dict = new Dictionary<int, int[]>();
                    foreach (var jobKey in json.Keys)
                    {
                        var job = int.Parse(jobKey);
                        var equipArray = LitJson.JsonMapper.ToObject<int[]>(json[jobKey].ToJson());
                        dict.Add(job, equipArray);
                    }
                    m_RecommandEquips.Add(config.Lv, dict);
                }
 
                if (realmPoolOpenLevel == 0 && config.expRate != 0)
                {
                    realmPoolOpenLevel = config.Lv;
                }
 
                if (config.NeedEquip != null && config.NeedEquip.Length > 1)
                {
                    m_RealmEquipConditions.Add(config.Lv, new RealmLevelUpEquipCondition()
                    {
                        level = config.NeedEquip[0],
                        starLevel = config.NeedEquip[1],
                        isSuit = config.NeedEquip[2] == 1,
                        itemColor = config.NeedEquip.Length > 3 ? config.NeedEquip[3] : 0,
                    });
                }
            }
 
            var funcConfig = FuncConfigConfig.Get("RealmExpTime");
            realmExpTime = int.Parse(funcConfig.Numerical1);
 
            funcConfig = FuncConfigConfig.Get("RealmEqiupDisplayLevel");
            realmEquipDisplayLevel = int.Parse(funcConfig.Numerical1);
            realmPoolRedpointPercent = int.Parse(funcConfig.Numerical2);
 
        }
 
        public bool TryGetRealmProperty(int level, out Dictionary<int, int> propertyDict)
        {
            return m_RealmProperties.TryGetValue(level, out propertyDict);
        }
 
        public bool TryGetRealmStages(int index, out List<int> stages)
        {
            stages = null;
            if (index < m_RealmStages.Count)
            {
                stages = m_RealmStages[index];
                return true;
            }
            return false;
        }
 
        public bool TryGetRealmPreviewEquips(int level, int job, out int[] equips)
        {
            equips = null;
            if (m_RealmPreviewEquips.ContainsKey(level))
            {
                return m_RealmPreviewEquips[level].TryGetValue(job, out equips);
            }
            return false;
        }
 
        public bool TryGetRecommandEquips(int level, int job, out int[] equips)
        {
            equips = null;
            if (m_RecommandEquips.ContainsKey(level))
            {
                return m_RecommandEquips[level].TryGetValue(job, out equips);
            }
            return false;
        }
 
        public bool TryGetRealmEquipCondition(int level, out RealmLevelUpEquipCondition equipCondition)
        {
            return m_RealmEquipConditions.TryGetValue(level, out equipCondition);
        }
        
        public bool TryLevelUp(out int error)
        {
            error = 0;
            var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
            if (realmLevel >= realmMaxLevel)
            {
                error = 100;
                return false;
            }
            var config = RealmConfig.Get(realmLevel);
            
            if (PlayerDatas.Instance.baseData.LV < config.NeedLV)
            {
                error = 1;
                return false;
            }
            if (config.BossID != 0 && !isBossPass)
            {
                error = 2;
                return false;
            }
            int equipError = 0;
            if (!SatisfyEquipCondition(realmLevel, out equipError))
            {
                error = equipError;
                return false;
            }
            if (config.NeedGood != 0)
            {
                var count = packModel.GetItemCountByID(PackType.Item, config.NeedGood);
                if (count < config.NeedNum)
                {
                    error = 3;
                    return false;
                }
            }
            return true;
        }
 
        private void TryPlayRealmEffect()
        {
            if (realmEffect != null)
            {
                if (realmEffect.IsPlaying)
                {
                    return;
                }
                else
                {
                    realmEffectCount--;
                    realmEffect = null;
                }
            }
            if (realmEffectCount > 0)
            {
                if (WindowCenter.Instance.IsOpen<MainInterfaceWin>()
                  && !WindowCenter.Instance.ExistAnyFullScreenOrMaskWin())
                {
                    realmEffect = EffectMgr.Instance.PlayUIEffect(7047, 1800, WindowCenter.Instance.uiRoot.baseCanvas, false);
                }
            }
        }
 
        public bool IsUnlockEquipRealm(int realmLevel, out int level)
        {
            level = 0;
            var equipSets = equipModel.GetAllEquipSets();
            var index = equipSets.FindIndex((x) =>
            {
                var equipSet = equipModel.GetEquipSet(x);
                if (equipSet != null)
                {
                    return equipSet.realm == realmLevel;
                }
                return false;
            });
            if (index != -1)
            {
                level = equipSets[index];
                return true;
            }
            return false;
        }
 
        public bool IsBuffActive(DateTime time)
        {
            return buffSeconds > 0
                    && expStartTime.AddTicks(TimeSpan.TicksPerSecond * buffSeconds) > time;
        }
 
        public bool SatisfyEquipCondition(int realmLevel, out List<int> notSatisfyPlaces)
        {
            notSatisfyPlaces = null;
            RealmLevelUpEquipCondition equipCondition;
            if (!TryGetRealmEquipCondition(realmLevel, out equipCondition))
            {
                return true;
            }
            notSatisfyPlaces = new List<int>();
            for (int i = 1; i <= 8; i++)
            {
                var equipGuid = equipModel.GetEquip(new Int2(equipCondition.level, i));
                var itemModel = packModel.GetItemByGuid(equipGuid);
                if (itemModel != null)
                {
                    if (equipCondition.isSuit)
                    {
                        if (itemModel.config.SuiteiD == 0)
                        {
                            notSatisfyPlaces.Add(i);
                            continue;
                        }
                    }
                    else
                    {
                        if (itemModel.config.ItemColor < equipCondition.itemColor)
                        {
                            notSatisfyPlaces.Add(i);
                            continue;
                        }
                    }
 
                    var starLevel = equipStarModel.GetEquipStarLevel(new Int2(equipCondition.level, i));
 
                    if (starLevel < equipCondition.starLevel)
                    {
                        notSatisfyPlaces.Add(i);
                    }
                }
                else
                {
                    notSatisfyPlaces.Add(i);
                }
            }
            return notSatisfyPlaces.Count == 0;
        }
 
        public bool SatisfyEquipCondition(int realmLevel, out int error)
        {
            error = 0;
            RealmLevelUpEquipCondition equipCondition;
            if (!TryGetRealmEquipCondition(realmLevel, out equipCondition))
            {
                return true;
            }
            for (int i = 1; i <= 8; i++)
            {
                var equipGuid = equipModel.GetEquip(new Int2(equipCondition.level, i));
                var itemModel = packModel.GetItemByGuid(equipGuid);
                if (itemModel != null)
                {
                    if (equipCondition.isSuit)
                    {
                        if (itemModel.config.SuiteiD == 0)
                        {
                            error = 4;
                            return false;
                        }
                    }
                    else
                    {
                        if (itemModel.config.ItemColor < equipCondition.itemColor)
                        {
                            error = 4;
                            return false;
                        }
                    }
 
                    var starLevel = equipStarModel.GetEquipStarLevel(new Int2(equipCondition.level, i));
 
                    if (starLevel < equipCondition.starLevel)
                    {
                        error = 5;
                        return false;
                    }
                }
                else
                {
                    error = 4;
                    return false;
                }
            }
            return true;
        }
 
        public bool HasEquipCondition(int realmLevel)
        {
            return m_RealmEquipConditions.ContainsKey(realmLevel);
        }
 
        public int GetRealmStage(int realmLevel)
        {
            if (realmLevel == 0)
            {
                return 0;
            }
            for (int i = 0; i < m_RealmStages.Count; i++)
            {
                var stages = m_RealmStages[i];
                var index = stages.IndexOf(realmLevel);
                if (index != -1)
                {
                    if (stages.Count == 1)
                    {
                        return i - 1;
                    }
                    return i;
                }
            }
            return m_RealmStages.Count - 1;
        }
 
        public int GetRealmStageEffect(int realmLevel)
        {
            var config = RealmConfig.Get(realmLevel);
            if (config != null)
            {
                switch (config.Quality)
                {
                    case 1: return 7028;
                    case 2: return 7029;
                    case 3: return 7030;
                    case 4: return 7031;
                    case 5: return 7032;
                    case 6: return 7033;
                }
            }
            return 7028;
        }
 
        public int GetRealmCoverEffect(int realmLevel)
        {
            var config = RealmConfig.Get(realmLevel);
            if (config != null)
            {
                switch (config.Quality)
                {
                    case 1: return 7039;
                    case 2: return 7040;
                    case 3: return 7041;
                    case 4: return 7042;
                    case 5: return 7043;
                    case 6: return 7044;
                }
            }
            return 7039;
        }
 
        public int GetRealmLineEffect(int realmLevel)
        {
            var config = RealmConfig.Get(realmLevel);
            if (config != null)
            {
                switch (config.Quality)
                {
                    case 1: return 7034;
                    case 2: return 7059;
                    case 3: return 7060;
                    case 4: return 7061;
                    case 5: return 7062;
                    case 6: return 7063;
                }
            }
            return 7034;
        }
 
        public bool GetBossEffectShow(int realmLevel)
        {
            var playerId = PlayerDatas.Instance.baseData.PlayerID;
            return LocalSave.GetBool(StringUtility.Contact("RealmBossEffect_", realmLevel, "_", playerId));
        }
 
        public void SetBossEffectShow(int realmLevel)
        {
            var playerId = PlayerDatas.Instance.baseData.PlayerID;
            LocalSave.SetBool(StringUtility.Contact("RealmBossEffect_", realmLevel, "_", playerId), true);
        }
 
        public bool SatisfyChallengeBoss(int reamLevel)
        {
            var config = RealmConfig.Get(reamLevel);
            if (config != null)
            {
                return config.BossID != 0 && !isBossPass && PlayerDatas.Instance.baseData.LV >= config.NeedLV;
            }
            return false;
        }
 
        public void SendLevelUpRealm()
        {
            CA523_tagCMRealmLVUp pak = new CA523_tagCMRealmLVUp();
            GameNetSystem.Instance.SendInfo(pak);
        }
 
        public void TryPushRealmPoolMessage()
        {
            return;
            var remainTime = 0f;
            var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
            var config = RealmConfig.Get(realmLevel);
            if (realmLevel >= realmPoolOpenLevel && config.expRate != 0)
            {
                if (totalExp < config.expLimit)
                {
                    float surplusExp = config.expLimit - totalExp;
                    if (buffSeconds > 0)
                    {
                        var expRate = config.expRate + config.expRate * (buffAddRate / 10000f);
                        var times = buffSeconds / realmExpTime;
                        if (times * expRate >= surplusExp)
                        {
                            remainTime = Mathf.CeilToInt(surplusExp / expRate) * realmExpTime;
                            surplusExp = 0;
                        }
                        else
                        {
                            remainTime = times * realmExpTime;
                            surplusExp = surplusExp - times * expRate;
                        }
                    }
                    if (surplusExp > 0)
                    {
                        remainTime += Mathf.CeilToInt(surplusExp / config.expRate) * realmExpTime;
                    }
                }
            }
            if (remainTime > 0f)
            {
                var json = pushModel.GetPushJsonData(11403, (int)remainTime,
                    Language.Get("RealmPoolGeTui_Title"), Language.Get("RealmPoolGeTui_Content"));
                pushModel.SendPushInfo(json);
            }
            else
            {
                pushModel.RemovePushInfo(11403);
            }
        }
 
        public void ReceivePackage(HA311_tagMCSyncRealmInfo package)
        {
            int beforeAwardState = xxzlAwardState;
            isBossPass = package.IsPass == 1;
            xxzlAwardState = (int)package.XXZLAwardState;
            bool isOver = false;
            if (beforeAwardState != 0 && beforeAwardState != xxzlAwardState && IsRealmXXZLOver())
            {
                isOver = true;
            }
            xxzlStateRefresh?.Invoke(isOver);
            RefreshRedpoint();
        }
 
        public void ReceivePackage(HA327_tagMCRealmExpInfo package)
        {
            expStartTime = TimeUtility.GetTime(package.BeginTime);
            startExp = package.CurExpPoint * (long)Constants.ExpPointValue + package.CurExp;
            buffAddRate = package.BuffAddRate;
            buffSeconds = package.BuffTime;
            if (realmExpRefresh != null)
            {
                realmExpRefresh();
            }
            //RefreshRealmPoolRedpoint();
 
            TryPushRealmPoolMessage();
        }
 
        private void OnStageLoadFinish()
        {
            if (!(StageLoad.Instance.currentStage is DungeonStage))
            {
                cacheMapId = 0;
            }
            else
            {
                var mapId = PlayerDatas.Instance.baseData.MapID;
                if (cacheMapId == REALM_DUNGEON_ID
                    && mapId != REALM_DUNGEON_ID)
                {
                    SnxxzGame.Instance.StartCoroutine(Co_TryOpenRealmWin());
                }
                cacheMapId = mapId;
            }
        }
 
        private void OnSystemNotifyEvent(string key)
        {
            if (key == "BigRealmUpSuccess")
            {
                if (WindowCenter.Instance.IsOpen<MainInterfaceWin>()
                  && !WindowCenter.Instance.ExistAnyFullScreenOrMaskWin())
                {
                    if (realmEffectCount < 2)
                    {
                        realmEffectCount++;
                        TryPlayRealmEffect();
                    }
                }
            }
        }
 
        private void PlayerDataRefreshEvent(PlayerDataType dataType)
        {
            if (dataType == PlayerDataType.RealmLevel
                || dataType == PlayerDataType.LV
                || dataType == PlayerDataType.FightPoint)
            {
                redpointDirty = true;
            }
 
            if (dataType == PlayerDataType.RealmLevel)
            {
                //显示不超过当前的大境界塔层
                var config = RealmTowerConfig.Get(currentFloor);
                if (config != null)
                {
                    int largeRealm = Math.Max(1, RealmConfig.Get(RealmTowerConfig.Get(currentFloor).NeedRealmLV).LvLarge);
                    int largeRealmNow = Math.Max(1, RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel).LvLarge);
                    if (largeRealm > largeRealmNow)
                    {
                        selectFloorID = passedFloor;
                    }
                    else
                    {
                        selectFloorID = currentFloor;
                    }
                }
                else
                {
                    selectFloorID = passedFloor;
                }
            }
        }
 
        private void RefreshItemCountEvent(PackType packType, int arg2, int itemId)
        {
            if (packType == PackType.Item)
            {
                var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
                if (config != null && config.NeedGood == itemId)
                {
                    redpointDirty = true;
                }
            }
            if (packType == PackType.Equip)
            {
                redpointDirty = true;
            }
        }
 
        IEnumerator Co_TryOpenRealmWin()
        {
            yield return WaitingForSecondConst.WaitMS1000;
            TryOpenRealmWin();
        }
 
        private void TryOpenRealmWin()
        {
            if (NewBieCenter.Instance.inGuiding)
            {
                return;
            }
            var treasureModel = ModelCenter.Instance.GetModel<TreasureModel>();
            if (treasureModel.newGotShowing)
            {
                return;
            }
            if (WindowCenter.Instance.ExistAnyFullScreenOrMaskWin())
            {
                return;
            }
            WindowCenter.Instance.Open<RealmTransitionWin>();
        }
 
        public void SetDayRemind()
        {
            if (realmDailyRedpoint.state == RedPointState.Simple)
            {
                DayRemind.Instance.SetDayRemind(DayRemind.DAILYREALMREDPOINT, true);
                RefreshRedpoint();
            }
        }
 
 
 
        void RefreshRedpoint()
        {
            var levelUpable = false;
            var challengeable = false;
            var dailyRedpointable = false;
            levelUpRedpoint.state = RedPointState.None;
            challengeRedpoint.state = RedPointState.None;
            realmDailyRedpoint.state = RedPointState.None;
            towerRedpoint.state = RedPointState.None;
 
            if (!IsRealmXXZLOver())
                return;
 
            if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Realm))
            {
                var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
                if (realmLevel < realmMaxLevel)
                {
                    var config = RealmConfig.Get(realmLevel);
                    if (SatisfyChallengeBoss(realmLevel))
                    {
                        challengeable = PlayerDatas.Instance.baseData.FightPoint >= (ulong)config.FightPower;
                    }
 
                    var error = 0;
                    if (TryLevelUp(out error))
                    {
                        levelUpable = true;
                    }
                }
 
                if (realmLevel >= realmPoolOpenLevel)
                {
                    if (!DayRemind.Instance.GetDayRemind(DayRemind.DAILYREALMREDPOINT))
                    {
                        dailyRedpointable = true;
                    }
                }
 
                if (GetErrorOfChallenge() == 0)
                {
                    towerRedpoint.state = RedPointState.Simple;
                }
            }
 
            levelUpRedpoint.state = levelUpable ? RedPointState.Simple : RedPointState.None;
            challengeRedpoint.state = challengeable ? RedPointState.Simple : RedPointState.None;
            realmDailyRedpoint.state = dailyRedpointable ? RedPointState.Simple : RedPointState.None;
 
            //RefreshRealmPoolRedpoint();
        }
 
        //void RefreshRealmPoolRedpoint()
        //{
        //    var isPoolFull = false;
        //    if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Realm))
        //    {
        //        var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
        //        if (realmLevel >= realmPoolOpenLevel)
        //        {
        //            var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
        //            if (totalExp >= config.expLimit * (realmPoolRedpointPercent / 100f))
        //            {
        //                isPoolFull = true;
        //            }
        //        }
        //    }
 
        //    realmPoolRedpoint.state = isPoolFull ? RedPointState.Simple : RedPointState.None;
        //}
 
        #region 修仙之路
 
 
        public int selectXXZL;
 
        //任务完成进度
        public bool IsRealmXXZLMissionFinish(int missionID, out int process)
        {
            var config = RealmXXZLConfig.Get(missionID);
            bool isFinish = false;
            process = 0;
            switch (config.TaskType)
            {
                case 1:
                    isFinish = treasureModel.IsTreasureCollected(config.NeedValue);
                    process = isFinish ? 1 : 0;
                    break;
                case 2:
                    process = ModelCenter.Instance.GetModel<SkyTowerModel>().highestPassFloor;
                    isFinish = process >= config.NeedValue;
                    break;
                case 3:
                    process = ModelCenter.Instance.GetModel<WorldBossModel>().killCntTotal;
                    isFinish = process >= config.NeedValue;
                    break;
                case 4:
                    process = (int)ModelCenter.Instance.GetModel<DailyQuestModel>().ActivityPlaceInfo.TotalCount;
                    isFinish = process >= config.NeedValue;
                    break;
                case 5:
                    isFinish = ModelCenter.Instance.GetModel<PersonalBossModel>().IsFBPass(config.NeedValue);
                    process = isFinish ? 1 : 0;
                    break;
                case 6:
                    process = ModelCenter.Instance.GetModel<DungeonModel>().GetAllEnterTimes(60010);
                    isFinish = process >= config.NeedValue;
                    break;
                case 7:
                    process = ModelCenter.Instance.GetModel<ReikiRootModel>().GetReikiRootTotalPointWithFree();
                    isFinish = process >= config.NeedValue;
                    break;
            }
 
            return isFinish;
        }
 
        public bool IsRealmXXZLOver()
        {
            var count = RealmXXZLConfig.GetKeys().Count;
            return xxzlAwardState == (Math.Pow(2, count + 1) - 2);
        }
 
        public int GetXXZLProcess()
        {
            var ids = RealmXXZLConfig.GetKeys();
            int process = 0;
            foreach (var id in ids)
            {
                if (IsGetAward(int.Parse(id)))
                {
                    process++;
                }
            }
            return process;
        }
 
        public bool IsGetAward(int missionID)
        {
            return (xxzlAwardState & (int)Math.Pow(2, missionID)) != 0;
        }
 
        void RefreshXXZLRedpoint()
        {
            xxzlRedpoint.state = RedPointState.None;
            if (IsRealmXXZLOver())
            {
                WindowCenter.Instance.windowBeforeOpenEvent -= OnBeforeWindowOpen;
                return;
            }
            var ids = RealmXXZLConfig.GetKeys();
            foreach (var id in ids)
            {
                int process;
                if (!IsGetAward(int.Parse(id)) && IsRealmXXZLMissionFinish(int.Parse(id), out process))
                {
                    xxzlRedpoint.state = RedPointState.Simple;
                    return;
                }
            }
        }
 
        void OnBeforeWindowOpen(Window window)
        {
            if (window.name == "MainInterfaceWin")
            {
                RefreshXXZLRedpoint();
            }
        }
 
        public void FocusSelectIndex()
        {
            var ids = RealmXXZLConfig.GetKeys();
            int index = -1;
            foreach (var id in ids)
            {
                int missionID = int.Parse(id);
                int process;
                var state = IsGetAward(missionID);
                bool isFinish = IsRealmXXZLMissionFinish(missionID, out process);
                if (!state && isFinish)
                {
                    selectXXZL = missionID - 1;
                    return;
                }
                else if (!state && !isFinish && index == -1)
                {
                    index = missionID - 1;
                }
            }
 
            selectXXZL = index;
        }
        #endregion
 
        #region 境界塔
        public void RequestChallenge()
        {
            var error = GetErrorOfChallenge();
            if (error == 0)
            {
                dungeonModel.RequestChallangeDungeon(Tower_MapId, 0);
            }
            else
            {
                switch (error)
                {
                    case 1:
                        SysNotifyMgr.Instance.ShowTip("BossRealmHint2", RealmTowerConfig.Get(selectFloorID).NeedRealmLV);
                        break;
                    default:
                        break;
                }
            }
        }
 
        //0 可挑战 1 境界不足 2 已通关
        private int GetErrorOfChallenge()
        {
            if (selectFloorID == 0)
                return 1;
 
            if (RealmTowerConfig.Get(selectFloorID).NeedRealmLV > PlayerDatas.Instance.baseData.realmLevel)
            {
                return 1;
            }
            if (selectFloorID <= passedFloor)
            {
                //已通关
                return 2;
            }
            return 0;
        }
 
        public void UpdateRealmTowerInfo(HB217_tagMCRealmTowerInfo netPack)
        {
            passedFloor = (int)netPack.Floor;
 
            //显示不超过当前的大境界塔层
            var config = RealmTowerConfig.Get(currentFloor);
            if (config != null)
            {
                int largeRealm = Math.Max(1, RealmConfig.Get(RealmTowerConfig.Get(currentFloor).NeedRealmLV).LvLarge);
                int largeRealmNow = Math.Max(1, RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel).LvLarge);
                if (largeRealm > largeRealmNow)
                {
                    selectFloorID = passedFloor;
                }
                else
                {
                    selectFloorID = currentFloor;
                }
            }
            else
            {
                selectFloorID = passedFloor;
            }
            RefreshRedpoint();
            OnTowerPassEvent?.Invoke();
        }
 
        public void RequestRefreshMonster()
        {
            var sendInfo = new CA508_tagCMDoFBAction();
            sendInfo.ActionType = 0;
            sendInfo.ActionInfo = (uint)currentFloor;
            GameNetSystem.Instance.SendInfo(sendInfo);
        }
        #endregion
    }
 
    public struct RealmLevelUpEquipCondition
    {
        public int level;
        public int starLevel;
        public bool isSuit;
        public int itemColor;
    }
}