少年修仙传客户端代码仓库
client_linchunjie
2019-04-17 11997ece0dc4980eba3dd8889d37adb8376e14cb
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, March 19, 2018
//--------------------------------------------------------
using System;
using System.Collections.Generic;
 
using Snxxz.UI;
//月卡投资
namespace Snxxz.UI {
 
    public class MonthlyInvestmentClass
    {
        public int ID;//ID
        public int Type;//类型
        public int NeedDay;//需要天数
        public int NeedLv;//需要等级
        public MonthlyInvestmentModel.MonthlyInvestmentItem monthlyInvestmentItem;//奖励
    }
    [XLua.LuaCallCSharp]
    public class MonthlyInvestmentModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
        public Dictionary<int, MonthlyInvestmentClass> MonthlyInvestmentDic = new Dictionary<int, MonthlyInvestmentClass>();
        public Dictionary<int, int> InfoSeriors = new Dictionary<int, int>();//奖励领取信息
        public event Action MonthlyInvestmentUpdating;
        private int tagAwardGet=0;//奖励信息
        public int Days=0;//当前天数
        public int InvestGold = 0;//投资额度
        public override void Init()
        {
            Assignment();
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            InfoSeriors.Clear();
            Days = 0;
            InvestGold = 0;
        }
 
        public void OnPlayerLoginOk()
        {
           
        }
 
        public override void UnInit()
        {
            
        }
        public void GetInfoSeriors(HA337_tagMCGoldInvestInfo vNetData)//接受信息
        {
         
            if (vNetData.InvestType == 1)
            {
                Days = (int)vNetData.CurDay;//当前天数
                InvestGold = (int)vNetData.InvestGold;
                if (vNetData.InvestRewardList.Length > 1)
                {
                    InfoSeriors.Clear();
                    for (int i = 0; i < vNetData.InvestRewardList.Length; i++)
                    {
                        InfoSeriors.Add((int)vNetData.InvestRewardList[i].RewardIndex, (int)vNetData.InvestRewardList[i].RewardValue);
                    }
                }
                else
                {
                    for (int i = 0; i < vNetData.InvestRewardList.Length; i++)
                    {
                        if (InfoSeriors.ContainsKey((int)vNetData.InvestRewardList[i].RewardIndex))
                        {
                            InfoSeriors[(int)vNetData.InvestRewardList[i].RewardIndex] = (int)vNetData.InvestRewardList[i].RewardValue;
                        }
                    }
                }
 
            }
            if (MonthlyInvestmentUpdating != null)
            {
                MonthlyInvestmentUpdating();
            }
        }
 
        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 bool IsTagGetInfoSeriors(int index)
        {
            if (InfoSeriors.ContainsKey(index))
            {
                if (InfoSeriors[index] == 0)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                return true;
            }
        }
        public bool IsTagGet(int _index)
        {
            return (tagAwardGet & (1 << _index)) != 0;
        }
        public class MonthlyInvestmentItem
        {
            private Dictionary<int, List<Item>> m_AwardDict = new Dictionary<int, List<Item>>();
 
            public List<Item> GetAwardItem(int _job)
            {
                List<Item> _items = null;
                m_AwardDict.TryGetValue(_job, out _items);
                return _items;
            }
            public void Add(int _job, Item _item)
            {
                List<Item> _list = null;
                if (!m_AwardDict.TryGetValue(_job, out _list))
                {
                    _list = new List<Item>();
                    m_AwardDict.Add(_job, _list);
                }
                _list.Add(_item);
            }
        }
       
        public void Assignment()
        {
            var investConfig = InvestConfig.GetValues();
            foreach (var value in investConfig)
            {
                if (value.type == 1 && !MonthlyInvestmentDic.ContainsKey(value.needDay))
                {
                    MonthlyInvestmentClass monthlyInvestment = new MonthlyInvestmentClass();
                    monthlyInvestment.ID = value.id;
                    monthlyInvestment.Type = value.type;
                    monthlyInvestment.NeedDay = value.needDay;
                    monthlyInvestment.NeedLv = value.needLV;
                    MonthlyInvestmentItem _monthyItem = new 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++)
                        {
                            _monthyItem.Add(_job, new Item(_itemArray[j][0], _itemArray[j][1]));
                        }
                    }
                    monthlyInvestment.monthlyInvestmentItem = _monthyItem;
                    MonthlyInvestmentDic.Add(value.needDay, monthlyInvestment);
                }
 
            }
        }
    }
 
}