少年修仙传客户端代码仓库
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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace vnxbqy.UI
{
    
    public class FlashSaleModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize, IOpenServerActivity
    {
        StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
        public override void Init()
        {
            OperationTimeHepler.Instance.operationStartEvent += OperationStartEvent;
            OperationTimeHepler.Instance.operationEndEvent += OperationEndEvent;
            OperationTimeHepler.Instance.operationAdvanceEvent += OperationAdvanceEvent;
            TimeMgr.Instance.OnDayEvent += OnDayEvent;
            OpenServerActivityCenter.Instance.Register(4, this);
        }
 
        public void OnBeforePlayerDataInitialize()
        {
        }
 
        public void OnPlayerLoginOk()
        {
            UpdateRedpoint();
        }
 
        public override void UnInit()
        {
            OperationTimeHepler.Instance.operationStartEvent -= OperationStartEvent;
            OperationTimeHepler.Instance.operationEndEvent -= OperationEndEvent;
            OperationTimeHepler.Instance.operationAdvanceEvent -= OperationAdvanceEvent;
            TimeMgr.Instance.OnDayEvent -= OnDayEvent;
        }
 
        private void OperationEndEvent(Operation type, int state)
        {
            if (type == Operation.FlashSale && state == 0)
            {
                UpdateRedpoint();
                if (onStateUpdate != null)
                {
                    onStateUpdate(4);
                }
            }
        }
 
        private void OperationAdvanceEvent(Operation type)
        {
            if (type == Operation.FlashSale)
            {
                if (onStateUpdate != null)
                {
                    onStateUpdate(4);
                }
            }
        }
 
        private void OperationStartEvent(Operation type, int state)
        {
            if (type == Operation.FlashSale && state == 0)
            {
                UpdateRedpoint();
                if (onStateUpdate != null)
                {
                    onStateUpdate(4);
                }
            }
        }
 
        private void OnDayEvent()
        {
            UpdateRedpoint();
        }
 
        public void SetDayRemind()
        {
            if (flashSaleRedpoint.state == RedPointState.Simple)
            {
                DayRemind.Instance.SetDayRemind(DayRemind.FLASHSALE_REDPOINT, true);
                UpdateRedpoint();
            }
        }
 
        public bool IsOpen
        {
            get
            {
                return OperationTimeHepler.Instance.SatisfyOpenCondition(Operation.FlashSale);
            }
        }
 
        public bool priorityOpen
        {
            get
            {
                return flashSaleRedpoint.state == RedPointState.Simple;
            }
        }
 
        public bool IsAdvance
        {
            get
            {
                return OperationTimeHepler.Instance.SatisfyAdvanceCondition(Operation.FlashSale);
            }
        }
 
        public void SendBuyFlashSale(OperationFlashSale.FlashSaleGift gift)
        {
            OperationBase operationBase;
            if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashSale, out operationBase))
            {
                OperationFlashSale operation = operationBase as OperationFlashSale;
                if (operation.InAdvanceTime(TimeUtility.ServerNow))
                {
                    var seconds = operation.GetSecondsBeforeStart(TimeUtility.ServerNow);
                    SysNotifyMgr.Instance.ShowTip("FlashSaleAdvanceLimit", TimeUtility.SecondsToHMS(seconds));
                    return;
                }
                if (!operation.InTime(TimeUtility.ServerNow))
                {
                    SysNotifyMgr.Instance.ShowTip("ActiveOutTime");
                    return;
                }
                if (!gift.Equals(default(OperationFlashSale.FlashSaleGift)))
                {
                    var buyInfo = storeModel.GetBuyShopLimit((uint)gift.id);
                    var buyCount = 0;
                    if (buyInfo != null)
                    {
                        buyCount = buyInfo.BuyCnt;
                    }
                    if (buyCount >= gift.limitNum)
                    {
                        return;
                    }
 
                    if (UIHelper.GetMoneyCnt(gift.moneyType) < (ulong)gift.moneyNumber)
                    {
                        switch (gift.moneyType)
                        {
                            case 1:
                                if (VersionConfig.Get().isBanShu)
                                {
                                    SysNotifyMgr.Instance.ShowTip("GoldErr");
                                    return;
                                }
                                WindowCenter.Instance.Open<RechargeTipWin>();
                                break;
                            default:
                                SysNotifyMgr.Instance.ShowTip("LackMoney", gift.moneyType);
                                break;
                        }
                        return;
                    }
                    if (gift.moneyType == 1)
                    {
                        ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),
                        Language.Get("OSTimeLimitGiftConfirm", gift.moneyNumber), (bool isOk) =>
                        {
                            if (isOk)
                            {
                                C0803_tagCBuyItemList pak = new C0803_tagCBuyItemList();
                                pak.NPCID = 0;
                                pak.BuyItemIndex = (ushort)gift.id;
                                pak.BuyCount = 1;
                                GameNetSystem.Instance.SendInfo(pak);
                            }
                        });
                    }
                    else
                    {
                        C0803_tagCBuyItemList pak = new C0803_tagCBuyItemList();
                        pak.NPCID = 0;
                        pak.BuyItemIndex = (ushort)gift.id;
                        pak.BuyCount = 1;
                        GameNetSystem.Instance.SendInfo(pak);
                    }
                }
            }
            else
            {
                SysNotifyMgr.Instance.ShowTip("ActiveOutTime");
            }
 
        }
 
        public bool HasNotBuyGift()
        {
            OperationBase operationBase;
            OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashSale, out operationBase);
            if (operationBase != null && operationBase.InTime(TimeUtility.ServerNow))
            {
                OperationFlashSale operation = operationBase as OperationFlashSale;
                OperationFlashSale.FlashSale flashShop;
                if (operation.TryGetFlashSale(TimeUtility.ServerNow, out flashShop))
                {
                    for (int i = 0; i < flashShop.gifts.Length; i++)
                    {
                        var gift = flashShop.gifts[i];
                        var buyInfo = storeModel.GetBuyShopLimit((uint)gift.id);
                        if (buyInfo == null || buyInfo.BuyCnt < gift.limitNum)
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
 
        public Redpoint flashSaleRedpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, 20904);
 
        public event Action<int> onStateUpdate;
 
        private void UpdateRedpoint()
        {
            flashSaleRedpoint.state = RedPointState.None;
            if (IsOpen && HasNotBuyGift() && !DayRemind.Instance.GetDayRemind(DayRemind.FLASHSALE_REDPOINT))
            {
                flashSaleRedpoint.state = RedPointState.Simple;
            }
        }
    }
}