少年修仙传客户端代码仓库
client_linchunjie
2018-09-06 520a55769c8a533659be0c1d53dcc8548024e496
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, April 26, 2018
//--------------------------------------------------------
using System;
using System.Collections.Generic;
using TableConfig;
using Snxxz.UI;
using System.Linq;
//仙玉投资
public class FairyJadeInvestmentClass
{
    public int ID;//ID
    public int Type;//类型
    public int NeedDay;//需要天数
    public int NeedLv;//需要等级
    public MonthlyInvestmentModel.MonthlyInvestmentItem FairyJadeInvestmentItem;//奖励
}
public class FairyJadeInvestmentModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk, IOpenServerActivity
{
    public Dictionary<int, FairyJadeInvestmentClass> FairyJadeInvestmentDic = new Dictionary<int, FairyJadeInvestmentClass>();//等级
    public Dictionary<int, int> InfoSeriors = new Dictionary<int, int>();//奖励领取信息//key为索引,Value(0,未领,其他值未领的钱数)
    public Dictionary<int, int> InvestmentAmountDic = new Dictionary<int, int>();//投资金额
    public static Action FairyJadeInfoSeriorsUpdate;
    public int InvestGold = 0; // 投资额度
    public int InvestmentGrade = 0;//0未投,1档,2,档,3,档,4档
    public int SelectNumber = 0;//记录想要投资的钱数
    public int RecordSelectNumberMax = 0;//用来标记最大可投资额度
    public List<int> MultipleList = new List<int>();
    VipInvestModel m_VipInvestModel;
    VipInvestModel VipInvestModel { get { return m_VipInvestModel ?? (m_VipInvestModel = ModelCenter.Instance.GetModel<VipInvestModel>()); } }
 
    public event Action<int> onStateUpate;
    public bool IsOpen
    {
        get
        {
            return IsOpenFeatures();
        }
    }
 
    public bool priorityOpen
    {
        get
        {
            return IsRedPoint();
        }
    }
 
 
    private bool IsRedPoint()//红点
    {
 
        if (redPointStre1.state == RedPointState.None)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    private bool IsOpenFeatures()//功能是否开启
    {
        bool isOpen = false;
        if (InvestmentGrade > 0 && InvestmentGrade < 4)
        {
            isOpen = true;
        }
        else
        {
            if (InvestmentGrade == 4)
            {
                foreach (int key in InfoSeriors.Keys)
                {
                    if (InfoSeriors[key] != 4)
                    {
                        isOpen = true;
                    }
                }
            }
        }
        if (PlayerDatas.Instance.baseData.LV >= 300 && !isOpen)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
 
    private bool IsOk = false;
    public bool IsRedpoint = false;
 
    private int DisplayLevel = 0;//显示等级
    private int DisplayDays = 0;//显示天数
    public override void Init()
    {
        OpenServerActivityCenter.Instance.Register(10, this);
        var InvestRedPoint = Config.Instance.Get<FuncConfigConfig>("InvestRedPoint");
        DisplayLevel = int.Parse(InvestRedPoint.Numerical2);
        DisplayDays = int.Parse(InvestRedPoint.Numerical3);
 
        int[] MultipleIntList = ConfigParse.GetMultipleStr<int>(Config.Instance.Get<FuncConfigConfig>("JadeInvest").Numerical1);
        MultipleList.Clear();
        for (int i = 0; i < MultipleIntList.Length; i++)
        {
            MultipleList.Add(MultipleIntList[i]);
        }
        Assignment();
    }
 
    public void OnBeforePlayerDataInitialize()
    {
        IsOk = false;
        IsRedpoint = false;
        InvestGold = 0;
        InvestmentGrade = 0;
        SelectNumber = 0;
        RecordSelectNumberMax = 0;
        FairyJadeInvestmentDic.Clear();
        InvestmentAmountDic.Clear();
        InfoSeriors.Clear();
        Assignment();
    }
 
    public void OnPlayerLoginOk()
    {
        IsOk = true;
        InvestmentAmount();
        InvestmentRedPoint();
        IsShowRedPointSimple();
        PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= Updatefighting;
        PlayerDatas.Instance.PlayerDataRefreshInfoEvent += Updatefighting;
        FairyJadeInvestmentWin.FairyJadeInvestmentRedPointEvent -= FairyJadeInvestmentRedPoint;
        FairyJadeInvestmentWin.FairyJadeInvestmentRedPointEvent += FairyJadeInvestmentRedPoint;
    }
 
    private void FairyJadeInvestmentRedPoint()
    {
        RedPointSate();
    }
 
    private void Updatefighting(PlayerDataRefresh _tCDBPlayerRefresh)
    {
        if (_tCDBPlayerRefresh == PlayerDataRefresh.LV && InvestGold > 0)
        {
            InvestmentRedPoint();
        }
        if (_tCDBPlayerRefresh == PlayerDataRefresh.LV)
        {
            IsShowRedPointSimple();
        }
    }
 
    public override void UnInit()
    {
 
    }
    public void Assignment()
    {
        var InvestConfig = Config.Instance.GetAllValues<InvestConfig>();
        if (FairyJadeInvestmentDic.Count > 0)
        {
            return;
        }
        foreach (var value in InvestConfig)
        {
            if (value.type == 3 && !FairyJadeInvestmentDic.ContainsKey(value.needLV))
            {
                FairyJadeInvestmentClass fairyJadeInvestment = new FairyJadeInvestmentClass();
                if (value.id >= 310)
                {
                    fairyJadeInvestment.ID = value.id % 100;
                }
                else
                {
                    fairyJadeInvestment.ID = value.id % 10;
                }
                if (!InfoSeriors.ContainsKey(fairyJadeInvestment.ID))
                {
                    InfoSeriors.Add(fairyJadeInvestment.ID, 0);
                }
                fairyJadeInvestment.Type = value.type;
                fairyJadeInvestment.NeedDay = value.needDay;
                fairyJadeInvestment.NeedLv = value.needLV;
                MonthlyInvestmentModel.MonthlyInvestmentItem FairyJadeItem = new MonthlyInvestmentModel.MonthlyInvestmentItem();
                var _jsonData = LitJson.JsonMapper.ToObject(value.award);
                foreach (string key in _jsonData.Keys)
                {
                    var _job = int.Parse(key);
                    var _itemArray = LitJson.JsonMapper.ToObject<int[][]>(_jsonData[key].ToJson());
                    for (int j = 0; j < _itemArray.Length; j++)
                    {
                        FairyJadeItem.Add(_job, new AwardItem()
                        {
                            item = new Item(_itemArray[j][0], _itemArray[j][1]),
                            isBind = _itemArray[j][2],
                        });
                    }
                }
                fairyJadeInvestment.FairyJadeInvestmentItem = FairyJadeItem;
                FairyJadeInvestmentDic.Add(value.needLV, fairyJadeInvestment);
            }
        }
    }
    public void GetInfoSeriors(HA337_tagMCGoldInvestInfo vNetData)//接受信息
    {
        if (vNetData.InvestType == 3)
        {
            InvestmentAmount();
            InvestGold = (int)vNetData.InvestGold;
            if (InvestmentAmountDic.ContainsKey(InvestGold))
            {
                InvestmentGrade = InvestmentAmountDic[InvestGold];
            }
            else
            {
                InvestmentGrade = 0;
            }
            for (int i = 0; i < vNetData.RewardRecordCnt; i++)
            {
                if (InfoSeriors.ContainsKey((int)vNetData.InvestRewardList[i].RewardIndex))
                {
                    InfoSeriors[(int)vNetData.InvestRewardList[i].RewardIndex] = (int)vNetData.InvestRewardList[i].RewardValue;
                }
            }
            if (FairyJadeInfoSeriorsUpdate != null)
            {
                FairyJadeInfoSeriorsUpdate();
            }
            if (IsOk)
            {
                InvestmentRedPoint();
            }
        }
    }
 
    public void SendInvestment(int InvestType, int RewardIndex)//领取奖励
    {
        CA541_tagCMGetInvestReward CA541 = new CA541_tagCMGetInvestReward();
        CA541.InvestType = (byte)InvestType;
        CA541.RewardIndex = (byte)RewardIndex;
        GameNetSystem.Instance.SendInfo(CA541);
    }
 
    public void InvestmentMonthlyInvestment(int InvestType, int InvestGold)//仙玉投资
    {
        CA540_tagCMGoldInvest C540 = new CA540_tagCMGoldInvest();
        C540.InvestType = (byte)InvestType;
        C540.InvestGold = (uint)InvestGold;
        GameNetSystem.Instance.SendInfo(C540);
    }
 
    public void InvestmentAmount()
    {
        if (InvestmentAmountDic.Count <= 0)
        {
            InvestmentAmountDic.Add(VipInvestModel.GetInvestGold(3, 0), 1);
            InvestmentAmountDic.Add(VipInvestModel.GetInvestGold(3, 1), 2);
            InvestmentAmountDic.Add(VipInvestModel.GetInvestGold(3, 2), 3);
            InvestmentAmountDic.Add(VipInvestModel.GetInvestGold(3, 3), 4);
            RecordSelectNumberMax = VipInvestModel.GetInvestGold(3, 3);
        }
    }
 
    private const int Redpoint_key1 = 20910;
    public Redpoint redPointStre1 = new Redpoint(209, Redpoint_key1);//仙玉投资红点
    public int JumpInedx = 0;
 
 
 
    private void InvestmentRedPoint()//红点
    {
        JumpInedx = 0;
        int type = -1;
        redPointStre1.state = RedPointState.None;
        int PlayerLV = PlayerDatas.Instance.baseData.LV;
        foreach (var key in FairyJadeInvestmentDic.Keys)
        {
            type += 1;
            if (PlayerLV >= key)
            {
                int indexID = FairyJadeInvestmentDic[key].ID;
                if (InvestmentGrade != 0)
                {
                    int IsReceive = InfoSeriors[indexID];
                    if (IsReceive == 0)
                    {
                        redPointStre1.state = RedPointState.GetReward;
                        JumpInedx = type;
                        return;
                    }
                    else
                    {
                        List<AwardItem> fairyJadeInvestmentItem = FairyJadeInvestmentDic[key].FairyJadeInvestmentItem.GetAwardItem(InvestmentGrade);
                        int AtPresentNumber = 0;
                        if (IsReceive != 0)
                        {
                            List<AwardItem> fairyJadeInvestmentItemAdd = FairyJadeInvestmentDic[key].FairyJadeInvestmentItem.GetAwardItem(IsReceive);
                            AwardItem itemAdd = fairyJadeInvestmentItemAdd[0];
                            AtPresentNumber = itemAdd.item.count;
                        }
                        if (fairyJadeInvestmentItem[0].item.count > AtPresentNumber)
                        {
                            redPointStre1.state = RedPointState.GetReward;
                            JumpInedx = type;
                            return;
                        }
                    }
                }
            }
        }
        int type1 = -1;
        if (JumpInedx == 0 && InvestmentGrade != 0)
        {
            foreach (var key in FairyJadeInvestmentDic.Keys)
            {
                type1 += 1;
                if (key > PlayerLV)
                {
                    JumpInedx = type1;
                    return;
                }
            }
        }
    }
    private void RedPointSate()//月卡投资创角前三天红点
    {
        if (InvestGold > 0)
        {
            return;
        }
        if (IsRedpoint)
        {
            redPointStre1.state = RedPointState.Simple;
        }
        else
        {
            InvestmentRedPoint();
        }
    }
 
    private void IsShowRedPointSimple()
    {
        int GetDayOfYear = DateTime.Now.DayOfYear;
        string strKey = "IsOpenFiaryJadeRedPoint" + PlayerDatas.Instance.baseData.PlayerID;
        int day = LocalSave.GetInt(strKey);
        if (day != GetDayOfYear)
        {
            if (TimeUtility.CreateDays <= DisplayDays && redPointStre1.state == RedPointState.None
                && PlayerDatas.Instance.baseData.LV >= DisplayLevel)
            {
                LocalSave.SetInt(strKey, GetDayOfYear);
                IsRedpoint = true;
                RedPointSate();
            }
 
        }
    }
 
    public void MessageNotification()
    {
        var _funcOrder = 0;
        if (!OpenServerActivityCenter.Instance.IsAnyActivityOpen(out _funcOrder))
        {
            SysNotifyMgr.Instance.ShowTip("JadeInvestmentLimit1");//信息提示
            return;
        }
        else if (InvestmentGrade <= 0 && PlayerDatas.Instance.baseData.LV >= 300)
        {
            SysNotifyMgr.Instance.ShowTip("JadeInvestmentLimit2");//信息提示
            return;
        }
        else
        {
            bool isOpen = false;
            if (InvestmentGrade == 4)
            {
                foreach (int key in InfoSeriors.Keys)
                {
                    if (InfoSeriors[key] != 4)
                    {
                        isOpen = true;
                    }
                }
            }
            if (!isOpen && PlayerDatas.Instance.baseData.LV >= 300)
            {
                SysNotifyMgr.Instance.ShowTip("JadeInvestmentLimit3");//信息提示
                return;
            }
        }
 
    }
 
}