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;
|
}
|
}
|