少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
using System;
using UnityEngine;
 
namespace vnxbqy.UI
{
    
    public class MultipleRealmPointModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk, IOpenServerActivity
    {
        public Redpoint multipleRed = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, 20908);
        public string LocalRecord_Key;
        bool isNewDay = false;
        bool openNotify = false;
 
        public event Action<int> onStateUpdate;
 
        public override void Init()
        {
            OpenServerActivityCenter.Instance.Register(8, this);
            //StageLoad.Instance.onStageLoadFinish += CheckReconnect;
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            alreadyRealmPoint = 0;
            isNewDay = false;
        }
 
        public void OnAfterPlayerDataInitialize()
        {
 
        }
 
        public void OnPlayerLoginOk()
        {
            openNotify = false;
            LocalRecord_Key = StringUtility.Contact("MultipleRealmRecord", PlayerDatas.Instance.baseData.PlayerID);
            GlobalTimeEvent.Instance.secondEvent -= SecondEvent;
            GlobalTimeEvent.Instance.secondEvent += SecondEvent;
            CheckShowRed();
        }
 
        public override void UnInit()
        {
            StageLoad.Instance.onStageLoadFinish -= CheckReconnect;
        }
 
        public bool IsOpen
        {
            get
            {
                OperationBase operationBase;
                if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.MultipRealmPoint, out operationBase))
                {
                    var operation = operationBase as OperationMultipleRealmPoint;
                    return operation.InActiveTime(TimeUtility.ServerNow) && operation.SatisfyOpenCondition();
                }
                return false;
            }
        }
 
        public bool priorityOpen
        {
            get
            {
                return multipleRed.state == RedPointState.Simple;
            }
        }
 
        public bool IsAdvance
        {
            get
            {
                return OperationTimeHepler.Instance.SatisfyAdvanceCondition(Operation.MultipRealmPoint);
            }
        }
 
        public event Action UpdateRealmPointEvent;
        public int alreadyRealmPoint { get; private set; }
        public void SetAlreadyRealmPoint(int point)
        {
            alreadyRealmPoint = point;
            if(UpdateRealmPointEvent != null)
            {
                UpdateRealmPointEvent();
            }
        }
 
        private void CheckReconnect()
        {
            if (!(StageLoad.Instance.stageType == Stage.E_StageType.Dungeon))
            {
                CheckShowRed();
            }
        }
 
        private void SecondEvent()
        {
            if (IsOpen && !openNotify)
            {
                openNotify = true;
                CheckShowRed();
                if (onStateUpdate != null)
                {
                    onStateUpdate(8);
                }
            }
            else if (!IsOpen && openNotify)
            {
                openNotify = false;
                CheckShowRed();
                if (onStateUpdate != null)
                {
                    onStateUpdate(8);
                }
            }
        }
 
        public void CheckShowRed(bool isClick = false)
        {
            if (!IsOpen) return;
 
            if(!isNewDay)
            {
              
                if (!PlayerPrefs.HasKey(LocalRecord_Key))
                {
                    LocalSave.SetInt(LocalRecord_Key, TimeUtility.ServerNow.Day);
                    isNewDay = true;
                }
                else
                {
                    if (TimeUtility.ServerNow.Day != LocalSave.GetInt(LocalRecord_Key))
                    {
                        isNewDay = true;
                        LocalSave.SetInt(LocalRecord_Key, TimeUtility.ServerNow.Day);
                    }
                }
            }
             
            if(!isClick)
            {
                if (IsOpen && isNewDay)
                {
                    multipleRed.state = RedPointState.Simple;
                }
                else
                {
                    multipleRed.state = RedPointState.None;
                }
            }
            else
            {
                multipleRed.state = RedPointState.None;
            }
           
        }
    }
}