少年修仙传客户端代码仓库
client_Wu Xijin
2018-10-26 82931aabaaa3e479bc04e11630a77cd9c9dd5fe3
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
using System.Collections.Generic;
using System.Text;
namespace TableConfig
{
 
    public partial class ItemCompoundConfig : ConfigBase, IConfigPostProcess
    {
        private static Dictionary<int, Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>>> allComposeModelDict = new Dictionary<int, Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>>>();
        static Dictionary<int, List<ItemCompoundConfig>> ticketComposeDict = new Dictionary<int, List<ItemCompoundConfig>>();
        static Dictionary<int, Dictionary<DisplayItemArray, int[]>> displayItemDict = new Dictionary<int, Dictionary<DisplayItemArray, int[]>>();
        public void OnConfigParseCompleted()
        {
            if (!allComposeModelDict.ContainsKey(firstType))
            {
                Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> secondTypeDict = new Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>>();
                Dictionary<int, List<ItemCompoundConfig>> thirdTypeDict = new Dictionary<int, List<ItemCompoundConfig>>();
                List<ItemCompoundConfig> thirdModellist = new List<ItemCompoundConfig>();
                thirdModellist.Add(this);
                thirdTypeDict.Add(thirdType, thirdModellist);
                secondTypeDict.Add(secondType, thirdTypeDict);
                allComposeModelDict.Add(firstType, secondTypeDict);
            }
            else
            {
                if (!allComposeModelDict[firstType].ContainsKey(secondType))
                {
                    Dictionary<int, List<ItemCompoundConfig>> thirdTypeDict = new Dictionary<int, List<ItemCompoundConfig>>();
                    List<ItemCompoundConfig> thirdModellist = new List<ItemCompoundConfig>();
                    thirdModellist.Add(this);
                    thirdTypeDict.Add(thirdType, thirdModellist);
                    allComposeModelDict[firstType].Add(secondType, thirdTypeDict);
                }
                else
                {
                    if (!allComposeModelDict[firstType][secondType].ContainsKey(thirdType))
                    {
                        List<ItemCompoundConfig> thirdModellist = new List<ItemCompoundConfig>();
                        thirdModellist.Add(this);
                        allComposeModelDict[firstType][secondType].Add(thirdType, thirdModellist);
                    }
                    else
                    {
                        allComposeModelDict[firstType][secondType][thirdType].Add(this);
                    }
                }
 
            }
 
            int[] makeIDs = ConfigParse.GetMultipleStr<int>(makeID);
            int[] unfixedItemIDs = ConfigParse.GetMultipleStr<int>(unfixedItemID);
            int[] fixedItemIDs = ConfigParse.GetMultipleStr<int>(itemID);
            int[] fixedItemCounts = ConfigParse.GetMultipleStr<int>(itemCount);
            int[] unfixedDisplay = ConfigParse.GetMultipleStr<int>(unfixedItemDisplay);
            int[] fixedDisplay = ConfigParse.GetMultipleStr<int>(itemDisplay);
 
            if (!displayItemDict.ContainsKey(id))
            {
                Dictionary<DisplayItemArray, int[]> arrayDict = new Dictionary<DisplayItemArray, int[]>();
                arrayDict.Add(DisplayItemArray.MakeIds,makeIDs);
                arrayDict.Add(DisplayItemArray.UnfixedIds,unfixedItemIDs);
                arrayDict.Add(DisplayItemArray.UnfixedDisplay,unfixedDisplay);
                arrayDict.Add(DisplayItemArray.FixedIds,fixedItemIDs);
                arrayDict.Add(DisplayItemArray.FixedCounts, fixedItemCounts);
                arrayDict.Add(DisplayItemArray.FixedDisplay,fixedDisplay);
                displayItemDict.Add(id, arrayDict);
            }
 
            if (firstType == (int)ComposeFuncType.Ticket)
            {
                var makeItemArray = ConfigParse.GetMultipleStr<int>(makeID);
                for (int i = 0; i < makeItemArray.Length; i++)
                {
                    List<ItemCompoundConfig> list = null;
                    if (!ticketComposeDict.TryGetValue(makeItemArray[i], out list))
                    {
                        list = new List<ItemCompoundConfig>();
                        ticketComposeDict.Add(makeItemArray[i], list);
                    }
                    list.Add(this);
                }
            }
        }
 
        /// <summary>
        /// 得到第一合成类型的数据
        /// </summary>
        /// <param name="firstType"></param>
        /// <returns></returns>
        public static Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> GetFirstComposeTypeDict(int firstType)
        {
            Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> composeTypeDict = new Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>>();
            if (allComposeModelDict.ContainsKey(firstType))
            {
                foreach (var secondType in allComposeModelDict[firstType].Keys)
                {
                    Dictionary<int, List<ItemCompoundConfig>> thirdTypeDict = allComposeModelDict[firstType][secondType];
                    foreach (var thirdType in thirdTypeDict.Keys)
                    {
                        for (int i = 0; i < thirdTypeDict[thirdType].Count; i++)
                        {
                            ItemCompoundConfig compoundConfig = thirdTypeDict[thirdType][i];
                            if (compoundConfig.levelNeed <= PlayerDatas.Instance.baseData.LV)
                            {
                                if (!composeTypeDict.ContainsKey(secondType))
                                {
                                    Dictionary<int, List<ItemCompoundConfig>> tempThirdTypeDict = new Dictionary<int, List<ItemCompoundConfig>>();
                                    List<ItemCompoundConfig> configlist = new List<ItemCompoundConfig>();
                                    configlist.Add(compoundConfig);
                                    tempThirdTypeDict.Add(thirdType, configlist);
                                    composeTypeDict.Add(secondType, tempThirdTypeDict);
                                }
                                else
                                {
                                    if (!composeTypeDict[secondType].ContainsKey(thirdType))
                                    {
                                        List<ItemCompoundConfig> configlist = new List<ItemCompoundConfig>();
                                        configlist.Add(compoundConfig);
                                        composeTypeDict[secondType].Add(thirdType, configlist);
                                    }
                                    else
                                    {
                                        composeTypeDict[secondType][thirdType].Add(compoundConfig);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return composeTypeDict;
        }
 
        public static Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> GetAllFirstComposeTypeDict(int firstType)
        {
            if (allComposeModelDict.ContainsKey(firstType))
            {
                return allComposeModelDict[firstType];
            }
 
            return null;
        }
 
        public static ItemCompoundConfig GetItemCompoundByType(int firstType,int secondType, int thirdType)
        {
            if(allComposeModelDict.ContainsKey(firstType))
            {
                if(allComposeModelDict[firstType].ContainsKey(secondType))
                {
                    if(allComposeModelDict[firstType][secondType].ContainsKey(thirdType))
                    {
                        return allComposeModelDict[firstType][secondType][thirdType][0];
                    }
                }
            }
            return null;
        }
 
        public static bool TryGetTicketCompose(int _ticketId, out List<ItemCompoundConfig> list)
        {
            return ticketComposeDict.TryGetValue(_ticketId, out list);
        }
 
        public static int[] GetDisplayArrayByType(int id,DisplayItemArray display)
        {
            int[] array = null;
            if(displayItemDict.ContainsKey(id))
            {
                displayItemDict[id].TryGetValue(display,out array);
            }
            return array;
        }
 
    }
}