123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730 |
- using CommonLang;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using XmdsCommonServer.Plugin;
- namespace XmdsCommonServer.XLS.Data
- {
- /// <summary>
- /// 战斗技能配置表数据.
- /// </summary>
- public class XmdsSkillData
- {
- // justsogo : 保证DmgRate从0开始,顺序不能改动,需要添加的话,在ValueSet8后面加
- public enum XmdsSkillDataKey : int
- {
- CDTime = 0,
- TalentData,
- DmgRate,
- ValueSet,
- ValueSet2,
- ValueSet3,
- ValueSet4,
- ValueSet5,
- ValueSet6,
- ValueSet7,
- ValueSet8,
- canAuto,
- Max,
- }
- public enum XmdsSkillExtKey : int
- {
- Normal = 0, //默认值
- BossComActiveSkill = 1, //boss通用主动技能
- BossComPassiveSkill = 2, //boss通用被动技能
- }
- public const string ATK_TYPE_PHY = "物理";
- public const string ATK_TYPE_MAG = "魔法";
- private XmdsSkillValue [] mConfigArray = new XmdsSkillValue[(int)XmdsSkillDataKey.Max];
- //扩展属性
- public int SkillExt;
- #region 原始数据.
- /// <summary>
- /// 技能ID.
- /// </summary>
- public int SkillID;
- /// <summary>
- /// 仇恨值.
- /// </summary>
- public string HateRate;
- /// <summary>
- /// 天赋信息
- /// </summary>
- public string TalentData;
- /// <summary>
- /// 攻击类型.
- /// </summary>
- public string DmgType;
- /// <summary>
- /// 伤害倍数.
- /// </summary>
- public string DmgRate;
- /// <summary>
- /// 额外伤害.
- /// </summary>
- public string ExdDmgSet;
- /// <summary>
- /// 触发概率.
- /// </summary>
- public string Chance;
- /// <summary>
- /// 持续时长.
- /// </summary>
- public string BuffTime;
- /// <summary>
- /// 属性1含义.
- /// </summary>
- public string ValueAttribute1;
- /// <summary>
- /// 属性1.
- /// </summary>
- public string ValueSet;
- /// <summary>
- /// 属性2含义.
- /// </summary>
- public string ValueAttribute2;
- /// <summary>
- /// 属性2.
- /// </summary>
- public string ValueSet2;
- /// <summary>
- /// 属性3含义.
- /// </summary>
- public string ValueAttribute3;
- /// <summary>
- /// 属性3.
- /// </summary>
- public string ValueSet3;
- /// <summary>
- /// 属性4.
- /// </summary>
- public string ValueSet4;
- /// <summary>
- /// 额外
- /// </summary>
- public string ValueSet5;
- public string ValueSet6;
- public string ValueSet7;
- public string ValueSet8;
- /// <summary>
- /// CD时间.
- /// </summary>
- public string CDTime;
- /// <summary>
- /// 是否可以自动战斗.
- /// </summary>
- public string canAuto;
-
- /// <summary>
- /// 技能类型.
- /// </summary>
- public int SkillType;
- /** 技能破定值 */
- public int BreakShieldValue;
- //是否有伤害(1:伤害,2-治疗)
- public int DamageType = 0;
- #endregion
- public XmdsSkillValue GetParamValue(XmdsSkillDataKey key)
- {
- XmdsSkillValue ret = mConfigArray[(int)key];
- if (ret == null)
- {
- throw new Exception(string.Format("XmdsSkillData GetParamValue not exists Key = {0}", key));
- }
- return ret;
- }
- /// <summary>
- /// 将所有原始数据按需转成XmdsSkillValue.
- /// </summary>
- public void Init()
- {
- mConfigArray[(int)XmdsSkillDataKey.DmgRate] = CreateSkillValue(DmgRate);
- mConfigArray[(int)XmdsSkillDataKey.CDTime] = CreateSkillValue(CDTime);
- mConfigArray[(int)XmdsSkillDataKey.canAuto] = CreateSkillValue(canAuto);
- if(this.TalentData != null && this.TalentData.Length > 0)
- {
- mConfigArray[(int)XmdsSkillDataKey.TalentData] = CreateSkillValue(TalentData);
- }
- if (this.ValueSet != null && this.ValueSet.Length > 0)
- {
- mConfigArray[(int)XmdsSkillDataKey.ValueSet] = CreateSkillValue(ValueSet);
- }
- if (this.ValueSet2 != null && this.ValueSet2.Length > 0)
- {
- mConfigArray[(int)XmdsSkillDataKey.ValueSet2] = CreateSkillValue(ValueSet2);
- }
- if (this.ValueSet3 != null && this.ValueSet3.Length > 0)
- {
- mConfigArray[(int)XmdsSkillDataKey.ValueSet3] = CreateSkillValue(ValueSet3);
- }
- if (this.ValueSet4 != null && this.ValueSet4.Length > 0)
- {
- mConfigArray[(int)XmdsSkillDataKey.ValueSet4] = CreateSkillValue(ValueSet4);
- }
- //额外数值
- if (this.ValueSet5 != null && this.ValueSet5.Length > 0)
- {
- mConfigArray[(int)XmdsSkillDataKey.ValueSet5] = CreateSkillValue(ValueSet5);
- }
- //额外数值
- if (this.ValueSet6 != null && this.ValueSet6.Length > 0)
- {
- mConfigArray[(int)XmdsSkillDataKey.ValueSet6] = CreateSkillValue(ValueSet6);
- }
- //额外数值
- if (this.ValueSet7 != null && this.ValueSet7.Length > 0)
- {
- mConfigArray[(int)XmdsSkillDataKey.ValueSet7] = CreateSkillValue(ValueSet7);
- }
- //额外数值
- if (this.ValueSet8 != null && this.ValueSet8.Length > 0)
- {
- mConfigArray[(int)XmdsSkillDataKey.ValueSet8] = CreateSkillValue(ValueSet8);
- }
- }
- private XmdsSkillValue CreateSkillValue(string content)
- {
- XmdsSkillValue ret = null;
- ret = ParserContent(SkillID, content);
- return ret;
- }
- private XmdsSkillValue ParserContent(int id, string content)
- {
- XmdsSkillValue ret = null;
- try
- {
- if (!string.IsNullOrEmpty(content))
- {
- List<int> mValueMin = null;
- if (content.Contains(":"))
- {
- mValueMin = new List<int>();
- //截取;所得的数组.
- string[] strArray = null;
- if (content.Contains(";"))
- {
- strArray = content.Split(';');
- }
- else
- {
- strArray = new String[1];
- strArray[0] = content;
- }
- //截取:所得到的数组.
- string[] subArray = null;
- //完整数据已字符串形式存储.
- string[] ValueArray = new string[strArray.Length];
- //[1:34][2:55]或[3:44-55].
- for (int i = 0; i < strArray.Length; i++)
- {
- subArray = strArray[i].Split(':');
- if (subArray != null && subArray.Length == 2)
- {
- ValueArray[i] = subArray[1];
- }
- }
- //[34,34-44]
- if (ValueArray[0].Contains("-"))
- {
- string[] subArray2;
- List<int> mValueMax = new List<int>();
- int t = 0;
- for (int k = 0; k < ValueArray.Length; k++)
- {
- subArray2 = ValueArray[k].Split(',');
- t = Int32.Parse(subArray2[0]);
- mValueMin.Add(t);
- t = Int32.Parse(subArray2[1]);
- mValueMax.Add(t);
- XmdsSkillValue_DoubleArray temp = new XmdsSkillValue_DoubleArray(content);
- temp.SetValue(mValueMin, mValueMax);
- ret = temp;
- }
- }
- else if (ValueArray[0].Contains("_"))
- {
- if (ValueArray[0].Contains(","))
- {
- string[] subArray2;
- XmdsSkillValue_ListExt temp = new XmdsSkillValue_ListExt(content);
- List<IntIntData> tempArray = new List<IntIntData>();
- for (int k = 0; k < ValueArray.Length;)
- {
- subArray2 = ValueArray[k].Split(',');
- for (int l = 0; l < subArray2.Length; l++)
- {
- string[] subArray3 = subArray2[l].Split('_');
- tempArray.Add(new IntIntData(Int32.Parse(subArray3[0]), Int32.Parse(subArray3[1])));
- }
- temp.SetValue(tempArray);
- if (++k < ValueArray.Length)
- {
- tempArray = new List<IntIntData>();
- }
- }
- ret = temp;
- }
- else
- {
- XmdsSkillValueExt temp = new XmdsSkillValueExt(content);
- List<IntIntData> tempArray = new List<IntIntData>();
- for (int k = 0; k < ValueArray.Length; k++)
- {
- string[] subArray2 = ValueArray[k].Split('_');
- tempArray.Add(new IntIntData(Int32.Parse(subArray2[0]), Int32.Parse(subArray2[1])));
- }
- temp.SetValue(tempArray);
- ret = temp;
- }
- }
- else if(ValueArray[0].Contains(","))
- {
- string[] subArray2;
- XmdsSkillValue_List temp = new XmdsSkillValue_List(content);
- for (int k = 0; k < ValueArray.Length;)
- {
- subArray2 = ValueArray[k].Split(',');
- for(int l = 0; l < subArray2.Length; l++)
- {
- mValueMin.Add(Int32.Parse(subArray2[l]));
- }
- temp.SetValue(mValueMin);
- if(++k < ValueArray.Length)
- {
- mValueMin = new List<int>();
- }
- }
- ret = temp;
- }
- else
- {
- for (int k = 0; k < ValueArray.Length; k++)
- {
- mValueMin.Add(Int32.Parse(ValueArray[k]));
- }
- XmdsSkillValue_Array temp = new XmdsSkillValue_Array(content);
- temp.SetValue(mValueMin);
- ret = temp;
- }
- }
- else if(content.Contains(","))
- {
- XmdsSkillValue_Array temp = new XmdsSkillValue_Array(content);
- String [] subArray = content.Split(',');
- mValueMin = new List<int>();
- for (int l = 0; l < subArray.Length; l++)
- {
- mValueMin.Add(Int32.Parse(subArray[l]));
- }
- temp.SetValue(mValueMin);
- ret = temp;
- }
- else if (content.Contains("_"))
- {
- XmdsSkillValue_Array temp = new XmdsSkillValue_Array(content);
- String[] subArray = content.Split('_');
- mValueMin = new List<int>();
- for (int l = 0; l < subArray.Length; l++)
- {
- mValueMin.Add(Int32.Parse(subArray[l]));
- }
- temp.SetValue(mValueMin);
- ret = temp;
- }
- else
- {
- int v = Int32.Parse(content);
- ret = new XmdsSkillValue(content, false);
- ret.SetValue(v);
- }
- }
- }
- catch (Exception error)
- {
- throw new Exception(string.Format("技能 {0} 数据 {1} 解析错误:{2}", id, content, error.ToString()));
- }
- return ret;
- }
- }
- public class IntIntData
- {
- public int value1;
- public int value2;
- public IntIntData() { }
- public IntIntData(int value1, int value2)
- {
- this.value1 = value1;
- this.value2 = value2;
- }
- public void ReSet()
- {
- this.value1 = 0;
- this.value2 = 0;
- }
- }
- public class XmdsSkillValue
- {
- public static readonly XmdsSkillValue Default = new XmdsSkillValue("", false) { mValue = 0};
- protected string mContent = null;
- private bool mSingleCfg = true;
- private int mValue;
- public XmdsSkillValue(string content, bool subClass = true)
- {
- mContent = content;
- if (subClass)
- {
- mSingleCfg = false;
- }
- }
- public virtual int GetValue()
- {
- return mValue;
- }
- public bool IsSingleCfg()
- {
- return this.mSingleCfg;
- }
- public virtual int GetValue(int lv)
- {
- return mValue;
- }
- public virtual int GetValueExt(int lv)
- {
- return mValue;
- }
- public virtual int GetValue(int lv, int ext)
- {
- return mValue;
- }
- public virtual int GetValueExt(int lv, int ext)
- {
- return mValue;
- }
- internal void SetValue(int v)
- {
- mValue = v;
- }
- //[1->N]
- protected bool IsValid(int lv, int listCount)
- {
- if (0 < lv && lv <= listCount)
- {
- return true;
- }
- return false;
- }
- }
- public class XmdsSkillValueExt : XmdsSkillValue
- {
- protected List<IntIntData> mList = null;
- public XmdsSkillValueExt(string content) : base(content)
- {
- mContent = content;
- }
- internal void SetValue(List<IntIntData> list)
- {
- mList = list;
- }
- public override int GetValue(int lv)
- {
- //验证等级有效性.
- int k = 0;
- if (IsValid(lv, mList.Count))
- {
- k = lv - 1;
- }
- //else
- //{
- // XmdsBattleHelper.LogWarn(string.Format("XmdsSkillValue_Array get Value Error:skillcontent = {0}, lv = {1}", mContent, lv));
- //string stackInfo = new StackTrace().ToString();
- //XmdsBattleHelper.LogWarn("stackInfo : " + stackInfo);
- //}
- return mList[k].value1;
- }
- public override int GetValueExt(int lv)
- {
- //验证等级有效性.
- int k = 0;
- if (IsValid(lv, mList.Count))
- {
- k = lv - 1;
- }
- //else
- //{
- // XmdsBattleHelper.LogWarn(string.Format("XmdsSkillValue_Array get Value Error:skillcontent = {0}, lv = {1}", mContent, lv));
- //string stackInfo = new StackTrace().ToString();
- //XmdsBattleHelper.LogWarn("stackInfo : " + stackInfo);
- //}
- return mList[k].value2;
- }
- }
- public class XmdsSkillValue_Array : XmdsSkillValue
- {
- protected List<int> mMinList = null;
- public XmdsSkillValue_Array(string content) : base(content)
- {
- }
- internal void SetValue(List<int> list)
- {
- mMinList = list;
- if (mMinList == null || mMinList.Count == 0)
- {
- throw new Exception("无效的XmdsSkillValue_Array数据.");
- }
- }
- public override int GetValue(int lv)
- {
- //验证等级有效性.
- int k = 0;
- if(IsValid(lv, mMinList.Count))
- {
- k = lv - 1;
- }
- //else
- //{
- // XmdsBattleHelper.LogWarn(string.Format("XmdsSkillValue_Array get Value Error:skillcontent = {0}, lv = {1}", mContent, lv));
- //string stackInfo = new StackTrace().ToString();
- //XmdsBattleHelper.LogWarn("stackInfo : " + stackInfo);
- //}
- return mMinList[k];
- }
- }
- public class XmdsSkillValue_DoubleArray : XmdsSkillValue_Array
- {
- private static Random mRandom = new Random();
- protected List<int> mMaxList = null;
- public XmdsSkillValue_DoubleArray(string content) : base(content)
- {
- }
- internal void SetValue(List<int> minList, List<int> maxList)
- {
- mMinList = minList;
- mMaxList = maxList;
- if (mMinList == null || mMinList.Count == 0 || mMaxList == null || mMaxList.Count == 0 || mMinList.Count != mMaxList.Count)
- {
- throw new Exception("无效的XmdsSkillValue_DoubleArray数据.");
- }
- }
- public override int GetValue(int lv)
- {
- //验证等级有效性.
- int k = 0;
- if (IsValid(lv, mMinList.Count) || IsValid(lv, mMaxList.Count))
- {
- k = lv - 1;
- }
- else
- {
- XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_DoubleArray get Value Error:skillcontent = {0}", mContent));
- }
- int a = mMinList[k];
- int b = mMaxList[k];
- return mRandom.Next(a, b);
- }
- }
- public class XmdsSkillValue_List : XmdsSkillValue
- {
- protected List<List<int>> mList = null;
- public XmdsSkillValue_List(string content) : base(content)
- {
- mList = new List<List<int>>();
- }
- internal void SetValue(List<int> list)
- {
- if (list == null || list.Count == 0)
- {
- throw new Exception("无效的XmdsSkillValue_Array数据.");
- }
- else
- {
- mList.Add(list);
- }
- }
- public override int GetValue(int lv, int ext)
- {
- int k = 0;
- if(IsValid(lv, mList.Count))
- {
- k = lv - 1;
- }
- List<int> tempArray = mList[k];
- if(IsValid(ext, tempArray.Count))
- {
- return tempArray[ext-1];
- }
- else if(tempArray.Count > 0)
- {
- string stackInfo = new StackTrace().ToString();
- XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_List1 get Value Error:skillcontent = {0}访问lv,ext: {1}, {2}", mContent, lv, ext +
- ", stack: " + stackInfo));
- return tempArray[0];
- }
- XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_List2 get Value Error:skillcontent = {0}", mContent));
- return 0;
- }
- }
- public class XmdsSkillValue_ListExt : XmdsSkillValue
- {
- protected List<List<IntIntData>> mList = null;
- public XmdsSkillValue_ListExt(string content) : base(content)
- {
- mList = new List<List<IntIntData>>();
- }
- internal void SetValue(List<IntIntData> list)
- {
- if (list == null || list.Count == 0)
- {
- throw new Exception("无效的XmdsSkillValue_Array数据.");
- }
- else
- {
- mList.Add(list);
- }
- }
- public override int GetValue(int lv, int ext)
- {
- int k = 0;
- if (IsValid(lv, mList.Count))
- {
- k = lv - 1;
- }
- List<IntIntData> tempArray = mList[k];
- if (IsValid(ext, tempArray.Count))
- {
- return tempArray[ext - 1].value1;
- }
- else if (tempArray.Count > 0)
- {
- string stackInfo = new StackTrace().ToString();
- XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_ListExt 1 get Value Error:skillcontent = {0}@{1}@{2}@{3}", mContent, lv, ext, stackInfo));
- return tempArray[0].value1;
- }
- else
- {
- string stackInfo = new StackTrace().ToString();
- XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_ListExt 2 get Value Error:skillcontent = {0}@{1}@{2}@{3}", mContent, lv, ext, stackInfo));
- return 0;
- }
- }
- public override int GetValueExt(int lv, int ext)
- {
- int k = 0;
- if (IsValid(lv, mList.Count))
- {
- k = lv - 1;
- }
- List<IntIntData> tempArray = mList[k];
- if (IsValid(ext, tempArray.Count))
- {
- return tempArray[ext - 1].value2;
- }
- else if (tempArray.Count > 0)
- {
- string stackInfo = new StackTrace().ToString();
- XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_ListExt 3 get Value Error:skillcontent = {0},{1},{2},{3}", mContent, lv, ext, stackInfo));
- return tempArray[0].value2;
- }
- else
- {
- string stackInfo = new StackTrace().ToString();
- XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_ListExt 4 get Value Error:skillcontent = {0},{1},{2},{3}", mContent, lv, ext, stackInfo));
- return 0;
- }
- }
- }
- }
|