少年修仙传客户端代码仓库
client_Wu Xijin
2019-01-22 c249639c00811edb11d537d0dd55cf552cc5b2d0
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TableConfig;
using LitJson;
 
namespace Snxxz.UI
{
    public class JadeDynastyEquipModel : Model,IBeforePlayerDataInitialize,IAfterPlayerDataInitialize,IPlayerLoginOk
    {
        public int UnlockTowerLayer
        {
            get { return 0; }
        }
 
        PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
 
        public override void Init()
        {
            ParseFuncConfig();
            ParseSuitAttrConfig();
        }
 
        public void OnBeforePlayerDataInitialize()
        {
 
        }
 
        public void OnAfterPlayerDataInitialize()
        {
          
        }
 
        public void OnPlayerLoginOk()
        {
            
        }
 
        public override void UnInit()
        {
           
        }
 
        #region 解析表数据
        public Dictionary<int, int> lockEquipLayerDict { get; private set; }
        public Dictionary<int, List<int>> suitTypeDict { get; private set;}
        public void ParseFuncConfig()
        {
            lockEquipLayerDict = new Dictionary<int, int>();
            suitTypeDict = new Dictionary<int, List<int>>();
            var equipZhuXian = Config.Instance.Get<FuncConfigConfig>("EquipZhuXian");
            var lockEquipData = JsonMapper.ToObject(equipZhuXian.Numerical1);
            foreach(var key in lockEquipData.Keys)
            {
                int equipPlace = int.Parse(key);
                int towerLayer = int.Parse(lockEquipData[key].ToString());
                lockEquipLayerDict.Add(equipPlace,towerLayer);
            }
 
            var suitGroupData = JsonMapper.ToObject(equipZhuXian.Numerical2);
            foreach(var key in suitGroupData.Keys)
            {
                int groupType = int.Parse(key);
                var equipPlaces = suitGroupData[key];
                if(equipPlaces.IsArray)
                {
                    List<int> list = new List<int>();
                    suitTypeDict.Add(groupType,list);
                    for(int i = 0; i < equipPlaces.Count; i++)
                    {
                        var equipPlace = equipPlaces[i];
                        list.Add(int.Parse(equipPlace.ToString()));
                    }
                }
            }
        }
 
        public Dictionary<int, Dictionary<int, JadeDynastySuitAttrData>> suitAttrDict { get; private set; }
        public void ParseSuitAttrConfig()
        {
            suitAttrDict = new Dictionary<int, Dictionary<int, JadeDynastySuitAttrData>>();
            var suitConfigs = Config.Instance.GetAllValues<JadeDynastySuitAttrConfig>();
            foreach(var config in suitConfigs)
            {
                int suitLv = config.suiteLV;
                int type = config.suiteType;
                var suitAttrData = new JadeDynastySuitAttrData(config.id);
                if (!suitAttrDict.ContainsKey(type))
                {
                    var dict = new Dictionary<int, JadeDynastySuitAttrData>();
                    dict.Add(suitLv,suitAttrData);
                    suitAttrDict.Add(type,dict);
                }
                else
                {
                    var dict = suitAttrDict[type];
                    if(!dict.ContainsKey(suitLv))
                    {
                        dict.Add(suitLv, suitAttrData);
                    }
                }
            }
        }
 
        public class JadeDynastySuitAttrData
        {
            public int suitLv { get; private set; }
            public Dictionary<int, int> attrDict { get; private set; }
            public JadeDynastySuitAttrConfig suitAttrConfig { get; private set; }
 
            public JadeDynastySuitAttrData(int id)
            {
                suitLv = 0;
                attrDict = new Dictionary<int, int>();
                suitAttrConfig = Config.Instance.Get<JadeDynastySuitAttrConfig>(id);
                if(suitAttrConfig != null)
                {
                    suitLv = suitAttrConfig.suiteLV;
                    int[] attrIds = suitAttrConfig.attrIDList;
                    int[] attrValues = suitAttrConfig.attrValueList;
                    if(attrIds != null && attrValues != null)
                    {
                        for(int i = 0; i < attrIds.Length; i++)
                        {
                            int attrId = attrIds[i];
                            int attrValue = attrValues[i];
                            if(!attrDict.ContainsKey(attrId))
                            {
                                attrDict.Add(attrId, attrValue);
                            }
                            else
                            {
                                attrDict[attrId] += attrValue;
                            }
                        }
                    }
                }
            }
        }
        #endregion
 
        #region 封包
        #endregion
 
        public bool TryGetJadeDynastyEquipIndex(int equipPlace,out int equipIndex)
        {
            equipIndex = 0;
            if(equipPlace >= (int)RoleEquipType.JadeDynasty_Cloak && equipPlace <= (int)RoleEquipType.JadeDynasty_Sword4)
            {
                equipIndex = equipPlace - 121;
                return true;
            }
            return false;
        }
 
        public bool TryGetLockTowerLayer(int equipPlace,out int towerLayer)
        {
            towerLayer = 0;
            return lockEquipLayerDict.TryGetValue(equipPlace,out towerLayer);
        }
 
        public bool TryGetSuitType(int equipPlace,out int suitType)
        {
            suitType = 0;
            foreach(var type in suitTypeDict.Keys)
            {
                var equipPlaces = suitTypeDict[type];
                if(equipPlaces.Contains(equipPlace))
                {
                    suitType = type;
                    return true;
                }
            }
            return false;
        }
 
        public bool TryGetEquipPlaces(int equipPlace,out List<int> equipPlaces)
        {
            int suitType = 0;
            equipPlaces = null;
            bool isSuit = TryGetSuitType(equipPlace,out suitType);
            if(isSuit)
            {
                equipPlaces = suitTypeDict[suitType];
                return true;
            }
            return false;
        }
 
        public bool TryGetSuitAttrData(int equipPlace,int suitLv,out JadeDynastySuitAttrData suitAttrData)
        {
            suitAttrData = null;
            int suitType = 0;
            TryGetSuitType(equipPlace,out suitType);
            if(suitAttrDict.ContainsKey(suitType))
            {
                var dict = suitAttrDict[suitType];
                return dict.TryGetValue(suitLv,out suitAttrData);
            }
            return false;
        }
 
        public bool IsWillUnlockEquipPlace(int equipPlace)
        {
            int willUnlockPlace = 0;
            int unlockTowerLayer = UnlockTowerLayer;
            int minTowerLayer = 0;
            foreach(var key in lockEquipLayerDict.Keys)
            {
                int lockTowerLayer = lockEquipLayerDict[key];
                if (lockTowerLayer > unlockTowerLayer
                    && (minTowerLayer > lockTowerLayer || minTowerLayer == 0))
                {
                    willUnlockPlace = key;
                    minTowerLayer = lockTowerLayer;
                }
            }
 
            return willUnlockPlace == equipPlace && willUnlockPlace != 0;
        }
 
        public bool IsLockEquipPlace(int equipPlace)
        {
            int unlockTowerLayer = UnlockTowerLayer;
            int towerLayer = 0;
            bool isLock = TryGetLockTowerLayer(equipPlace,out towerLayer);
            if(isLock && towerLayer > unlockTowerLayer)
            {
                return true;
            }
            return false;
        }
 
        public bool TryGetMaxSuitLV(int equipPlace,out int maxSuitLv)
        {
            maxSuitLv = 0;
            var suitLvs = GetSuitLvList(equipPlace);
            if(suitLvs != null && suitLvs.Count > 0)
            {
                maxSuitLv = suitLvs[suitLvs.Count - 1];
                return true;
            }
            return false;
        }
 
        public List<int> GetSuitLvList(int equipPlace)
        {
            int suitType = 0;
            bool isSuit = TryGetSuitType(equipPlace,out suitType);
            if(suitAttrDict.ContainsKey(suitType))
            {
                var dict = suitAttrDict[suitType];
                return dict.Keys.ToList();
            }
            return null;
        }
 
        public bool TryGetIsActiveSuit(int equipPlace,int suitLV,out List<int> activeEquips)
        {
            activeEquips = new List<int>();
            List<int> equipPlaces = null;
            bool isSuit = TryGetEquipPlaces(equipPlace, out equipPlaces);
            var itemModel = playerPack.GetItemModelByIndex(PackType.rptJadeDynastyEquip,equipPlace);
            if(itemModel != null)
            {
                int equipLv = itemModel.chinItemModel.LV;
                if(equipLv >= suitLV)
                {
                    activeEquips = equipPlaces;
                    return true;
                }
            }
 
            if(equipPlaces != null)
            {
                foreach(var key in equipPlaces)
                {
                    var model = playerPack.GetItemModelByIndex(PackType.rptJadeDynastyEquip,key);
                    if(model != null)
                    {
                        int equipLv = model.chinItemModel.LV;
                        if (equipLv >= suitLV)
                        {
                            activeEquips.Add(key);
                        }
                    }
                }
            }
            return false;
        }
 
        public bool TryGetSuitLV(int equipPlace,PackType type,out int curSuitLv,out int nextSuitLV)
        {
            curSuitLv = 0;
            nextSuitLV = 0;
            int maxSuitLv = 0;
            bool isMax = TryGetMaxSuitLV(equipPlace,out maxSuitLv);
            switch(type)
            {
                case PackType.rptJadeDynastyItem:
                    if(isMax)
                    {
                        curSuitLv = maxSuitLv;
                        return true;
                    }
                    break;
                case PackType.rptJadeDynastyEquip:
                    int minEquipLv = 0;
                    var suitLvs = GetSuitLvList(equipPlace);
                    List<int> equipPlaces = null;
                    bool isSuit = TryGetEquipPlaces(equipPlace, out equipPlaces);
                    if (isSuit && equipPlaces != null)
                    {
                        foreach (var key in equipPlaces)
                        {
                            var model = playerPack.GetItemModelByIndex(type,key);
                            if(model != null 
                                && (minEquipLv > model.chinItemModel.LV
                                || minEquipLv == 0))
                            {
                                minEquipLv = model.chinItemModel.LV;
                            }
                            else if(model == null)
                            {
                                minEquipLv = 0;
                                break;
                            }
                        }
                    }
 
                    if(minEquipLv != 0 && suitLvs != null)
                    {
                        for(int i = suitLvs.Count - 1; i > -1; i++)
                        {
                            int suitLv = suitLvs[i];
                            if(minEquipLv >= suitLv)
                            {
                                curSuitLv = suitLv;
                                break;
                            }
                        }
 
                        foreach(var suitLv in suitLvs)
                        {
                            if(suitLv > minEquipLv)
                            {
                                nextSuitLV = suitLv;
                                break;
                            }
                        }
                    }
 
                    if(curSuitLv != 0 || nextSuitLV != 0)
                    {
                        return true;
                    }
                    break;
            }
 
            return false;
           
        }
 
        public bool TryGetSumSuitAttr(int suitType,PackType type,out JadeDynastySuitAttrData activeSuit,out JadeDynastySuitAttrData nextSuit)
        {
            activeSuit = null;
            nextSuit = null;
            if (!suitTypeDict.ContainsKey(suitType)) return false;
 
            int equipPlace = suitTypeDict[suitType][0];
            int curSuitLv = 0;
            int nextSuitLv = 0;
            bool isSuitLv = TryGetSuitLV(equipPlace,type,out curSuitLv,out nextSuitLv);
 
            TryGetSuitAttrData(equipPlace,curSuitLv,out activeSuit);
            TryGetSuitAttrData(equipPlace,nextSuitLv,out nextSuit);
 
            return activeSuit != null || nextSuit != null;
        }
    }
}