少年修仙传客户端代码仓库
leonard Wu
2018-08-03 c2d2d5d3a840bf50968b3f95e304929bc62a7b70
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
//--------------------------------------------------------
//    [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
{
    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,档
    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>()); } }
    private bool IsOk = false;
    public bool IsRedpoint = false;
    public override void Init()
    {
        int[] MultipleIntList = ConfigParse.GetMultipleStr<int>(ConfigManager.Instance.GetTemplate<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;
    }
 
    public void OnPlayerLoginOk()
    {
        IsOk = true;
        InvestmentAmount();
        InvestmentRedPoint();
        if (TimeUtility.CreateDays <= 3 && redPointStre1.state == RedPointState.None)
        {
            IsRedpoint = true;
            if (PlayerDatas.Instance.baseData.LV >= 30)
            {
                RedPointSate();
            }
        }
        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)
        {
            if (TimeUtility.CreateDays <= 3 && redPointStre1.state == RedPointState.None && PlayerDatas.Instance.baseData.LV >= 30)
            {
                if (IsRedpoint)
                {
                    RedPointSate();
                }
            }
        }
    }
 
    public override void UnInit()
    {
 
    }
    public void Assignment()
    {
        var InvestConfig = ConfigManager.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);
            RecordSelectNumberMax = VipInvestModel.GetInvestGold(3, 2);
        }
    }
 
    private const int Redpoint_key1 = 3502;
    public Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_VipDot, 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.Simple;
                        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.Simple;
                            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();
        }
    }
}