using Snxxz.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 SkillEffectValue GetSkillEffectValue(SkillConfig config)
|
{
|
if (config == null)
|
{
|
return default(SkillEffectValue);
|
}
|
return new SkillEffectValue()
|
{
|
effect1 = config.Effect1,
|
effect2 = config.Effect2,
|
effect3 = config.Effect3,
|
effect4 = config.Effect4,
|
effect5 = config.Effect5,
|
effect6 = config.Effect6,
|
};
|
}
|
}
|
|
public struct SkillEffectValue
|
{
|
public int effect1;
|
public int effect2;
|
public int effect3;
|
public int effect4;
|
public int effect5;
|
public int effect6;
|
|
const int INTERVAL = 1000000;
|
|
public override bool Equals(object obj)
|
{
|
var compare = (SkillEffectValue)obj;
|
return compare.effect1 == effect1 &&
|
compare.effect2 == effect2 &&
|
compare.effect3 == effect3 &&
|
compare.effect4 == effect4 &&
|
compare.effect5 == effect5 &&
|
compare.effect6 == effect6;
|
}
|
|
public override int GetHashCode()
|
{
|
var value = INTERVAL + effect1 + INTERVAL * 2 + effect2
|
+ INTERVAL * 3 + effect3 + INTERVAL * 4 + effect4
|
+ INTERVAL * 5 + effect5 + INTERVAL * 6 + effect6;
|
return value.GetHashCode();
|
}
|
}
|
|