少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
using vnxbqy.UI;
using System.Collections.Generic;
using System.Threading;
 
public partial class SkillConfig
{
    static Dictionary<int, int> horseSkills = new Dictionary<int, int>();
    /// <summary>
    /// 根据职业以及技能类型存储技能
    /// </summary>
    private static Dictionary<int, Dictionary<int, Dictionary<int, List<int>>>> m_Skills = new Dictionary<int, Dictionary<int, Dictionary<int, List<int>>>>();
 
    public static void SkillClassifingInit()
    {
        SkillClassifingConfig.Init(true);
        var configs = SkillClassifingConfig.GetValues();
        foreach (var config in configs)
        {
            var UseType = config.UseType;
            var FuncType = config.FuncType;
            var SkillTypeID = config.SkillTypeID;
            var SkillID = config.SkillID;
            var SkillLV = config.SkillLV;
 
            if (FuncType == 5)
            {
                horseSkills.Add(SkillTypeID * 1000 + SkillLV, SkillID);
            }
 
            Dictionary<int, Dictionary<int, List<int>>> funcDic = null;
            Dictionary<int, List<int>> typeDic = null;
            List<int> lvlist = null;
            m_Skills.TryGetValue(UseType, out funcDic);
            if (funcDic != null)
            {
                funcDic.TryGetValue(FuncType, out typeDic);
                if (typeDic != null)
                {
                    typeDic.TryGetValue(SkillTypeID, out lvlist);
                    if (lvlist != null)
                    {
                        lvlist.Add(SkillID);
                    }
                    else
                    {
                        lvlist = new List<int>();
                        lvlist.Add(SkillID);
                        typeDic.Add(SkillTypeID, lvlist);
                    }
                }
                else
                {
                    typeDic = new Dictionary<int, List<int>>();
                    lvlist = new List<int>();
                    lvlist.Add(SkillID);
                    typeDic.Add(SkillTypeID, lvlist);
                    funcDic.Add(FuncType, typeDic);
                }
            }
            else
            {
                funcDic = new Dictionary<int, Dictionary<int, List<int>>>();
                typeDic = new Dictionary<int, List<int>>();
                lvlist = new List<int>();
                lvlist.Add(SkillID);
                typeDic.Add(SkillTypeID, lvlist);
                funcDic.Add(FuncType, typeDic);
                m_Skills.Add(UseType, funcDic);
            }
        }
 
    }
 
    /// <summary>
    /// 根据职业类型以及技能类型获取技能
    /// </summary>
    /// <param name="occupy"></param>
    /// <param name="type"></param>
    /// <returns></returns>
    public static Dictionary<int, List<int>> GetSkillWithOccpyAndType(int occupy, int type)
    {
        Dictionary<int, Dictionary<int, List<int>>> dic = null;
        Dictionary<int, List<int>> typeDic = null;
        m_Skills.TryGetValue(occupy, out dic);
        if (dic != null)
        {
            dic.TryGetValue(type, out typeDic);
        }
        return typeDic;
    }
 
    public static List<int> GetSkills(int occupy, int type, int _typeId)
    {
        List<int> _list = null;
        Dictionary<int, List<int>> _dict = GetSkillWithOccpyAndType(occupy, type);
        if (_dict != null)
        {
            _dict.TryGetValue(_typeId, out _list);
        }
        return _list;
    }
 
    public static Dictionary<int, Dictionary<int, List<int>>> GetSkillActive(int occupy)
    {
        Dictionary<int, Dictionary<int, List<int>>> dic = null;
        m_Skills.TryGetValue(occupy, out dic);
        return dic;
    }
 
    //------坐骑技能获取
    public static SkillConfig GetSkillTypeIDAndSkillLV(int typeId, int level)
    {
        var skillId = 0;
        horseSkills.TryGetValue(typeId * 1000 + level, out skillId);
        return SkillConfig.Get(skillId);
    }
 
    public static int FindSkillByJob(int[] skillIds, int job)
    {
        foreach (var skill in skillIds)
        {
            var config = SkillConfig.Get(skill);
            if (config != null && (config.UseType == 0 || config.UseType == 1 << job))
            {
                return skill;
            }
        }
 
        return 0;
    }
 
    public static SkillEffectGroup GetSkillEffectValue(SkillConfig config)
    {
        if (config == null)
        {
            return default(SkillEffectGroup);
        }
        return new SkillEffectGroup()
        {
            effects = new int[6]
            {
                config.Effect1,
                config.Effect2,
                config.Effect3,
                config.Effect4,
                config.Effect5,
                config.Effect6,
            },
 
            valueGroups = new SkillEffectValueGroup[6]
            {
                new SkillEffectValueGroup()
                {
                    value1 = config.EffectValue11,
                    value2 = config.EffectValue12,
                    value3 = config.EffectValue13,
                },
                new SkillEffectValueGroup()
                {
                    value1 = config.EffectValue21,
                    value2 = config.EffectValue22,
                    value3 = config.EffectValue23,
                },
                new SkillEffectValueGroup()
                {
                    value1 = config.EffectValue31,
                    value2 = config.EffectValue32,
                    value3 = config.EffectValue33,
                },
                new SkillEffectValueGroup()
                {
                    value1 = config.EffectValue41,
                    value2 = config.EffectValue42,
                    value3 = config.EffectValue43,
                },
                new SkillEffectValueGroup()
                {
                    value1 = config.EffectValue51,
                    value2 = config.EffectValue52,
                    value3 = config.EffectValue53,
                },
                new SkillEffectValueGroup()
                {
                    value1 = config.EffectValue61,
                    value2 = config.EffectValue62,
                    value3 = config.EffectValue63,
                }
            },
        };
    }
 
    public static string GetSkillDescription(string description, float[] values)
    {
        switch (values.Length)
        {
            case 1:
                return string.Format(description, values[0]);
            case 2:
                return string.Format(description, values[0], values[1]);
            case 3:
                return string.Format(description, values[0], values[1], values[2]);
            case 4:
                return string.Format(description, values[0], values[1], values[2]
                    , values[3]);
            case 5:
                return string.Format(description, values[0], values[1], values[2]
                    , values[3], values[4]);
            case 6:
                return string.Format(description, values[0], values[1], values[2]
                    , values[3], values[4], values[5]);
            default:
                return description;
        }
    }
}
 
public struct SkillEffectGroup
{
    public int[] effects;
    public SkillEffectValueGroup[] valueGroups;
 
    const int INTERVAL = 1000000;
 
    public override bool Equals(object obj)
    {
        var compare = (SkillEffectGroup)obj;
        for (int i = 0; i < compare.effects.Length; i++)
        {
            if (compare.effects[i] == 511
                && effects[i] == 511)
            {
                if (!Is2ValueEquals(compare.valueGroups[i], valueGroups[i]))
                {
                    return false;
                }
            }
 
            if (compare.effects[i] != effects[i])
            {
                return false;
            }
        }
        return true;
    }
 
    bool Is2ValueEquals(SkillEffectValueGroup group1, SkillEffectValueGroup group2)
    {
        return group1.value1 == group2.value1 && group1.value2 == group2.value2;
    }
 
    public int GetHasValueCount()
    {
        var count = 0;
        for (int i = 0; i < effects.Length; i++)
        {
            if (effects[i] != 0)
            {
                count++;
            }
        }
        return count;
    }
 
    public float GetEffectValue(int index)
    {
        var value = 0f;
        if (index < effects.Length)
        {
            if (effects[index] == 511)
            {
                value = valueGroups[index].value3;
            }
            else
            {
                value = valueGroups[index].value1;
            }
 
            switch (effects[index])
            {
                case 7:
                case 9:
                    if (valueGroups[index].value2 == 3)
                    {
                        value = (float)System.Math.Round(value / 100f, 1);
                    }
                    break;
                default:
                    value = (float)System.Math.Round(value / 100f, 1);
                    break;
            }
        }
        return value;
    }
 
    public override int GetHashCode()
    {
        var value = 0;
        for (int i = 0; i < effects.Length; i++)
        {
            value += INTERVAL * i + effects[i];
        }
        for (int i = 0; i < valueGroups.Length; i++)
        {
            if (effects[i] == 511)
            {
                value += valueGroups[i].GetHashCode();
            }
        }
        return value.GetHashCode();
    }
}
 
public struct SkillEffectValueGroup
{
    public int value1;
    public int value2;
    public int value3;
 
    const int INTERVAL = 100000;
 
    public override int GetHashCode()
    {
        return INTERVAL + value1 + INTERVAL * 2 + value2;
    }
}