少年修仙传客户端代码仓库
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
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
namespace vnxbqy.UI
{
    
    public class OSTimeLimitGiftModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize, IOpenServerActivity
    {
        Dictionary<int, List<StoreConfig>> m_OSTimeLimitGifts = new Dictionary<int, List<StoreConfig>>();
 
        private DateTime m_OverdueTime = DateTime.Now;
        public DateTime overdueTime { get { return m_OverdueTime; } }
        public int openDays { get; private set; }
 
        public Redpoint redpoint { get; private set; }
 
        StoreModel m_StoreModel;
 
        public event Action<int> onStateUpdate;
 
        StoreModel storeModel
        {
            get
            {
                return m_StoreModel ?? (m_StoreModel = ModelCenter.Instance.GetModel<StoreModel>());
            }
        }
 
        public bool IsOpen
        {
            get
            {
                return currentDay <= openDays && FuncOpen.Instance.IsFuncOpen(132);
            }
        }
 
        public bool priorityOpen
        {
            get
            {
                return redpoint.state == RedPointState.Simple;
            }
        }
 
        public int currentDay
        {
            get
            {
                return TimeUtility.OpenDay + 1;
            }
        }
 
        public bool IsAdvance
        {
            get
            {
                return false;
            }
        }
 
        public override void Init()
        {
            var _openDay = 0;
            List<StoreConfig> _list = null;
            StoreConfig.TryGetStoreConfigs((int)StoreFunc.OSTimeLimitGift, out _list);
            if (_list != null)
            {
                for (int i = 0; i < _list.Count; i++)
                {
                    List<StoreConfig> _configs = null;
                    if (!m_OSTimeLimitGifts.TryGetValue(_list[i].LimitValue, out _configs))
                    {
                        _configs = new List<StoreConfig>();
                        m_OSTimeLimitGifts.Add(_list[i].LimitValue, _configs);
                    }
                    _configs.Add(_list[i]);
                    if (_list[i].LimitValue > _openDay)
                    {
                        _openDay = _list[i].LimitValue;
                    }
                }
            }
            openDays = _openDay;
 
            redpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, MainRedDot.REDPOINT_OPENSERVER * 100 + 3);
 
            TimeUtility.OnServerOpenDayRefresh += OnServerOpenDayRefresh;
            storeModel.RefreshBuyShopLimitEvent += UpdateRedpoint;
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
            OpenServerActivityCenter.Instance.Register(3, this);
        }
 
        private void OnServerOpenDayRefresh()
        {
            OnCreateRoleTimeRefresh();
        }
 
        public override void UnInit()
        {
            TimeUtility.OnServerOpenDayRefresh -= OnServerOpenDayRefresh;
            storeModel.RefreshBuyShopLimitEvent -= UpdateRedpoint;
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
        }
 
        public void OnBeforePlayerDataInitialize()
        {
 
        }
 
        public void OnPlayerLoginOk()
        {
            UpdateRedpoint();
        }
 
        private void OnCreateRoleTimeRefresh()
        {
            if (currentDay <= openDays)
            {
                m_OverdueTime = TimeUtility.ServerNow.AddDays(openDays - currentDay + 1);
                m_OverdueTime = new DateTime(m_OverdueTime.Year, m_OverdueTime.Month, m_OverdueTime.Day);
            }
            UpdateRedpoint();
        }
 
        private void OnFuncStateChangeEvent(int _id)
        {
            if (_id == 132)
            {
                UpdateRedpoint();
                if (onStateUpdate != null)
                {
                    onStateUpdate(3);
                }
            }
        }
 
        public bool TryGetGifts(int _day,out List<StoreConfig> _list)
        {
            return m_OSTimeLimitGifts.TryGetValue(_day, out _list);
        }
 
        public void SetDayRemind()
        {
            if (redpoint.state == RedPointState.Simple)
            {
                DayRemind.Instance.SetDayRemind(DayRemind.OSTIMEGIFT_REDPOINT, true);
                UpdateRedpoint();
            }
        }
 
        void UpdateRedpoint()
        {
            redpoint.state = RedPointState.None;
            if (currentDay > openDays || !FuncOpen.Instance.IsFuncOpen(132)
                || DayRemind.Instance.GetDayRemind(DayRemind.OSTIMEGIFT_REDPOINT))
            {
                return;
            }
            List<StoreConfig> _list;
            var day = Mathf.Max(1, currentDay);
            day = Mathf.Min(day, openDays);
            if (TryGetGifts(day, out _list))
            {
                for (int i = 0; i < _list.Count; i++)
                {
                    var _limit = storeModel.GetBuyShopLimit((uint)_list[i].ID);
                    if (_limit == null || _limit.BuyCnt < _list[i].GoumaiNumber[0])
                    {
                        redpoint.state = RedPointState.Simple;
                        break;
                    }
                }
            }
        }
    }
}