少年修仙传客户端代码仓库
client_linchunjie
2019-04-17 f1f2599ba0e6b64358ffef7ae5c9f9af3ed8b8b4
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, May 23, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
using System;
using System.Collections.Generic;
 
namespace Snxxz.UI
{
 
    [XLua.LuaCallCSharp]
    public class FirstTimeRechargeModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
 
        public bool IsOk = false;
 
        public int CumulativeTime;//获取累计时间
        public int FirstGoldTimeOut = 0;
        public static event Action<string> FirstTimeRechargeTiime;
        public static event Action FirstTimeRecharEffect;
        public bool IsPlayEffect = false;
        private bool IsStageLoadFinish = false;
        public bool IsTipShow = false;
        DateTime GetDateTime;
 
        //--------------------获取首冲试用数据
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        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 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);
        }
 
        public override void UnInit()
        {
        }
 
        private void windowBeforeClose(Window _window)
        {
            if (_window is MainInterfaceWin)
            {
                if (WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
                {
                    WindowCenter.Instance.Close<FirstTimeRechargeWin>();
                }
            }
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            IsTipShow = false;
            IsStageLoadFinish = false;
            IsOk = false;
            IsTryOut = 0;
            CumulativeTime = 0;
            IsPlayEffect = false;
        }
 
        public void OnPlayerLoginOk()
        {
            IsOk = true;
            if (!LocalSave.GetBool("FirstTimeRechargeBool", false))
            {
                LocalSave.SetBool("FirstTimeRechargeBool", true);
            }
 
            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.coinPointTotal <= 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.Close<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);
            }
        }
        private bool IsDungeon()
        {
            var mapId = PlayerDatas.Instance.baseData.MapID;
            var mapConfig = MapConfig.Get(mapId);
            return mapConfig != null && mapConfig.MapFBType != 0;
        }
 
        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.coinPointTotal <= 0 && second > 0 /*&& !inDungeon*/ && CumulativeTime - second > 0)
            {
                if (WindowCenter.Instance.IsOpen<MainInterfaceWin>() && !WindowCenter.Instance.ExistAnyFullScreenOrMaskWin() && !WindowCenter.Instance.IsOpen<ChatWin>())
                {
                    if (!WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
                    {
                        WindowCenter.Instance.Open<FirstTimeRechargeWin>();
                    }
 
                    int Residue = CumulativeTime - second;
                    string strTime = string.Empty;
                    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();
 
                    }
 
                    if (FirstTimeRechargeTiime != null)
                    {
                        FirstTimeRechargeTiime(strTime);
                    }
                }
                else
                {
                    if (WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
                    {
                        WindowCenter.Instance.Close<FirstTimeRechargeWin>();
                    }
                }
            }
            else
            {
                if (WindowCenter.Instance.IsOpen("FirstTimeRechargeWin"))
                {
                    WindowCenter.Instance.Close<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>();
            }
 
        }
 
    }
 
}