少年修仙传客户端代码仓库
client_Wu Xijin
2019-03-04 7268a79e72f4029b9fa2ccd50de756659c3166a6
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
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;
    }
 
}