少年修仙传客户端代码仓库
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
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, May 23, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
using System;
using System.Collections.Generic;
using LitJson;
 
namespace vnxbqy.UI
{
 
    
    public class FirstTimeRechargeModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
 
        public bool IsOk = false;
 
        public int CumulativeTime;//获取累计时间
        public int FirstGoldTimeOut = 0;
        public static event Action<string, bool> FirstTimeRechargeTiime;
        public static event Action FirstTimeRecharEffect;
        public bool IsPlayEffect = false;
        private bool IsStageLoadFinish = false;
        public bool IsTipShow = false;
        public bool IsShowOnce = false; //倒计时上线点击后不再显示,最后一分钟必显
        DateTime GetDateTime;
 
        //--------------------获取首冲试用数据
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
 
        public int IsTryOut = 0;//0-不可试用,1-可试用,2-已使用
        public Dictionary<int, int> TryOutDic = new Dictionary<int, int>();
        public int TryOutLv = 0;
        public static event Action<int> TryOutEvent;
        public event Action IsTipShowEvent;
        public int firstRechargeCTGID;
        public int firstRechargeMornCTGID;
        public int firstRechargeBetterCTGID;
        public override void Init()
        {
            string str = FuncConfigConfig.Get("FirstGoldTimeOut").Numerical1;
            FirstGoldTimeOut = int.Parse(str);
 
            var FirstGoldTryItem = FuncConfigConfig.Get("FirstGoldTryItem");
            TryOutDic.Clear();
            TryOutDic = ConfigParse.GetDic<int, int>(FirstGoldTryItem.Numerical1);
            TryOutLv = int.Parse(FirstGoldTryItem.Numerical4);
 
            int[] firstCTGIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("FirstGold").Numerical4);
            firstRechargeCTGID = firstCTGIDs[0];
            firstRechargeBetterCTGID = firstCTGIDs[1];
            firstRechargeMornCTGID = firstCTGIDs[2];
        }
 
        private void PlayerDataRefreshEvent(PlayerDataType dataType)
        {
            if (dataType != PlayerDataType.LV)
                return;
 
            if (PlayerDatas.Instance.baseData.LV > 150)
                return;
            if (PlayerDatas.Instance.baseData.LV % 30 == 0)
                //到达等级强制再显示一次
                IsShowOnce = false;
        }
 
 
        public override void UnInit()
        {
        }
 
        private void windowBeforeClose(Window _window)
        {
            if (_window is MainInterfaceWin)
            {
                if (WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
                {
                    WindowCenter.Instance.CloseImmediately("FirstTimeRechargeWin");
                }
            }
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            IsTipShow = false;
            IsStageLoadFinish = false;
            IsOk = false;
            IsTryOut = 0;
            CumulativeTime = 0;
            IsPlayEffect = false;
            needFirstRechargeMore = false;
        }
 
        public void OnPlayerLoginOk()
        {
            IsOk = true;
            if (!LocalSave.GetBool("FirstTimeRechargeBool", false))
            {
                LocalSave.SetBool("FirstTimeRechargeBool", true);
            }
            PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
            PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
            GlobalTimeEvent.Instance.secondEvent -= secondEvent;
            GlobalTimeEvent.Instance.secondEvent += secondEvent;
            WindowCenter.Instance.windowBeforeCloseEvent -= windowBeforeClose;
            WindowCenter.Instance.windowBeforeCloseEvent += windowBeforeClose;
            WindowCenter.Instance.windowBeforeOpenEvent -= windowBeforeOpenEvent;
            WindowCenter.Instance.windowBeforeOpenEvent += windowBeforeOpenEvent;
            StageLoad.Instance.onStageLoadFinish -= onStageLoadFinish;
            StageLoad.Instance.onStageLoadFinish += onStageLoadFinish;
            ItemOverdueModel.FirstGoldWPOver -= FirstGoldWPOver;
            ItemOverdueModel.FirstGoldWPOver += FirstGoldWPOver;
            FirstGoldWPOver();
        }
 
        private void FirstGoldWPOver()
        {
            bool IsExist = NewBieCenter.Instance.completeGuidesBuf.Contains(200);
            if (!IsExist && IsTryOut == 2 && PlayerDatas.Instance.baseData.coinTotal <= 0)
            {
                bool IsOver = false;
 
                int _weaponId = 0;
                if (ModelCenter.Instance.GetModel<PackModel>().GetSinglePack(PackType.Item) != null)
                {
                    var job = PlayerDatas.Instance.baseData.Job;
                    if (TryOutDic.ContainsKey(job))
                    {
                        var itemConfig = ItemConfig.Get(TryOutDic[job]);
                        _weaponId = itemConfig.EffectValueA1;
                    }
 
                    var list = packModel.GetSinglePack(PackType.Item).GetItemsById(_weaponId);
                    if (list != null && list.Count > 0)
                    {
                        for (int k = 0; k < list.Count; k++)
                        {
                            bool isOverdue = ItemLogicUtility.Instance.IsOverdue(list[k].guid);
                            if (isOverdue)
                            {
                                IsOver = isOverdue;
                            }
                        }
                    }
                }
                if (IsOver)
                {
                    var SendInfo = new CA222_tagCMSetGuideOK();
                    SendInfo.GuideIndex = 200;
                    SendInfo.IsOK = 1;
                    GameNetSystem.Instance.SendInfo(SendInfo);
                    IsTipShow = true;
                    if (IsTipShowEvent != null)
                    {
                        IsTipShowEvent();
                    }
                }
            }
        }
 
        private void onStageLoadFinish()
        {
            var inDungeon = IsDungeon();
            if (IsStageLoadFinish && !inDungeon)
            {
                OpenFirstChargeTrialWin();
                IsStageLoadFinish = false;
            }
 
        }
 
        private void windowBeforeOpenEvent(Window obj)
        {
            if ((!WindowCenter.Instance.IsOpen<MainInterfaceWin>() && WindowCenter.Instance.ExistAnyFullScreenOrMaskWin()) || obj is ChatWin)
            {
                if (WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
                {
                    WindowCenter.Instance.CloseImmediately("FirstTimeRechargeWin");
                }
            }
        }
 
        public void GetFirstTimeRecharge(HAA08_tagMCFirstGoldTime info)
        {
            CumulativeTime = (int)info.FirstGoldRemainTime;
            GetDateTime = DateTime.Now;
        }
 
        public void WhetherToTry(HAA02_tagMCFirstGoldInfo info)
        {
 
            IsTryOut = info.FirstGoldTry;
            var inDungeon = IsDungeon();
            if (inDungeon)
            {
                IsStageLoadFinish = true;
            }
            if (IsOk && IsTryOut == 1 && !inDungeon)
            {
                OpenFirstChargeTrialWin();
            }
            else if (IsOk && IsTryOut == 2)
            {
                if (WindowCenter.Instance.IsOpen<FirstChargeTrialWin>())
                {
                    WindowCenter.Instance.Close<FirstChargeTrialWin>();
                }
            }
            if (TryOutEvent != null)
            {
                TryOutEvent(IsTryOut);
            }
        }
 
        public bool IsShowTime()
        {
            TimeSpan ts = DateTime.Now - GetDateTime;
            int second = (int)ts.TotalSeconds;
            if (CumulativeTime != 0 && CumulativeTime > second)
                return true;
 
            return false;
        }
 
        public bool IsDungeon()
        {
            var isDungeon = MapUtility.IsDungeon(PlayerDatas.Instance.baseData.MapID);
            if (ClientDungeonStageUtility.isClientDungeon)
            {
                isDungeon = true;
            }
            return isDungeon;
        }
 
 
 
        private void secondEvent()
        {
            //var inDungeon = IsDungeon();
            TimeSpan ts = DateTime.Now - GetDateTime;
            int second = (int)ts.TotalSeconds;
            if (CumulativeTime != 0 && PlayerDatas.Instance.baseData.LV <= FirstGoldTimeOut && PlayerDatas.Instance.baseData.coinTotal <= 0 && second > 0 /*&& !inDungeon*/ && CumulativeTime - second > 0)
            {
                if (WindowCenter.Instance.IsOpen<MainInterfaceWin>() && !WindowCenter.Instance.ExistAnyFullScreenOrMaskWin() && !WindowCenter.Instance.IsOpen<ChatWin>())
                {
                    int Residue = CumulativeTime - second;
                    if (!WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
                    {
                        if (!IsShowOnce && Residue > 0 && !IsDungeon())
                            WindowCenter.Instance.Open<FirstTimeRechargeWin>();
                    }
 
                    string strTime = string.Empty;
                    bool isRed = false;
                    if (Residue / 60 > 0)
                    {
                        strTime = Residue / 60 + Language.Get("Minute") + Residue % 60 + Language.Get("RealmWin_Bewrite_35");
                    }
                    else
                    {
                        strTime = Residue % 60 + Language.Get("RealmWin_Bewrite_35");
                    }
                    if ((Residue / 60) < 5 && FirstTimeRecharEffect != null)
                    {
                        IsPlayEffect = true;
                        FirstTimeRecharEffect();
                        isRed = true;
 
                    }
 
                    if (FirstTimeRechargeTiime != null)
                    {
                        FirstTimeRechargeTiime(strTime, isRed);
                    }
                }
                else
                {
                    if (WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
                    {
                        WindowCenter.Instance.CloseImmediately("FirstTimeRechargeWin");
                    }
                }
            }
            else
            {
                if (WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
                {
                    WindowCenter.Instance.CloseImmediately("FirstTimeRechargeWin");
                }
            }
        }
 
        public void TryOutSend()//首冲试用
        {
            var sendInfo = new CA511_tagCMTryFirstGoldItem();
            GameNetSystem.Instance.SendInfo(sendInfo);
        }
 
        public void OpenFirstChargeTrialWin()
        {
            if (NewBieCenter.Instance.inGuiding || ModelCenter.Instance.GetModel<TreasureModel>().newGotShowing)
            {
                return;
            }
            if (!WindowCenter.Instance.IsOpen<FirstChargeTrialWin>() && IsTryOut == 1)
            {
                WindowCenter.Instance.Open<FirstChargeTrialWin>();
            }
 
        }
 
        public bool needFirstRechargeMore = false;  //已经充值过低档位首充的玩家,想要高级首充的方法
        public void AskFirstRechargeMore(string text)
        {
            if (text == Language.Get("FirstRecharge6"))
            {
                if (PlayerDatas.Instance.baseData.LV < 10)
                    return;
 
                VipModel.RechargeCount rechargeCount;
                vipModel.TryGetRechargeCount(firstRechargeMornCTGID, out rechargeCount);
                if (rechargeCount.totalCount > 0)
                    return;
                needFirstRechargeMore = true;
                WindowCenter.Instance.Open<FirstRechargeWin>();
            }
        }
 
    }
 
}