XmdsSkillData.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. using CommonLang;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using XmdsCommonServer.Plugin;
  6. namespace XmdsCommonServer.XLS.Data
  7. {
  8. /// <summary>
  9. /// 战斗技能配置表数据.
  10. /// </summary>
  11. public class XmdsSkillData
  12. {
  13. // justsogo : 保证DmgRate从0开始,顺序不能改动,需要添加的话,在ValueSet8后面加
  14. public enum XmdsSkillDataKey : int
  15. {
  16. CDTime = 0,
  17. TalentData,
  18. DmgRate,
  19. ValueSet,
  20. ValueSet2,
  21. ValueSet3,
  22. ValueSet4,
  23. ValueSet5,
  24. ValueSet6,
  25. ValueSet7,
  26. ValueSet8,
  27. canAuto,
  28. Max,
  29. }
  30. public enum XmdsSkillExtKey : int
  31. {
  32. Normal = 0, //默认值
  33. BossComActiveSkill = 1, //boss通用主动技能
  34. BossComPassiveSkill = 2, //boss通用被动技能
  35. }
  36. public const string ATK_TYPE_PHY = "物理";
  37. public const string ATK_TYPE_MAG = "魔法";
  38. private XmdsSkillValue [] mConfigArray = new XmdsSkillValue[(int)XmdsSkillDataKey.Max];
  39. //扩展属性
  40. public int SkillExt;
  41. #region 原始数据.
  42. /// <summary>
  43. /// 技能ID.
  44. /// </summary>
  45. public int SkillID;
  46. /// <summary>
  47. /// 仇恨值.
  48. /// </summary>
  49. public string HateRate;
  50. /// <summary>
  51. /// 天赋信息
  52. /// </summary>
  53. public string TalentData;
  54. /// <summary>
  55. /// 攻击类型.
  56. /// </summary>
  57. public string DmgType;
  58. /// <summary>
  59. /// 伤害倍数.
  60. /// </summary>
  61. public string DmgRate;
  62. /// <summary>
  63. /// 额外伤害.
  64. /// </summary>
  65. public string ExdDmgSet;
  66. /// <summary>
  67. /// 触发概率.
  68. /// </summary>
  69. public string Chance;
  70. /// <summary>
  71. /// 持续时长.
  72. /// </summary>
  73. public string BuffTime;
  74. /// <summary>
  75. /// 属性1含义.
  76. /// </summary>
  77. public string ValueAttribute1;
  78. /// <summary>
  79. /// 属性1.
  80. /// </summary>
  81. public string ValueSet;
  82. /// <summary>
  83. /// 属性2含义.
  84. /// </summary>
  85. public string ValueAttribute2;
  86. /// <summary>
  87. /// 属性2.
  88. /// </summary>
  89. public string ValueSet2;
  90. /// <summary>
  91. /// 属性3含义.
  92. /// </summary>
  93. public string ValueAttribute3;
  94. /// <summary>
  95. /// 属性3.
  96. /// </summary>
  97. public string ValueSet3;
  98. /// <summary>
  99. /// 属性4.
  100. /// </summary>
  101. public string ValueSet4;
  102. /// <summary>
  103. /// 额外
  104. /// </summary>
  105. public string ValueSet5;
  106. public string ValueSet6;
  107. public string ValueSet7;
  108. public string ValueSet8;
  109. /// <summary>
  110. /// CD时间.
  111. /// </summary>
  112. public string CDTime;
  113. /// <summary>
  114. /// 是否可以自动战斗.
  115. /// </summary>
  116. public string canAuto;
  117. /// <summary>
  118. /// 技能类型.
  119. /// </summary>
  120. public int SkillType;
  121. /** 技能破定值 */
  122. public int BreakShieldValue;
  123. //是否有伤害(1:伤害,2-治疗)
  124. public int DamageType = 0;
  125. #endregion
  126. public XmdsSkillValue GetParamValue(XmdsSkillDataKey key)
  127. {
  128. XmdsSkillValue ret = mConfigArray[(int)key];
  129. if (ret == null)
  130. {
  131. throw new Exception(string.Format("XmdsSkillData GetParamValue not exists Key = {0}", key));
  132. }
  133. return ret;
  134. }
  135. /// <summary>
  136. /// 将所有原始数据按需转成XmdsSkillValue.
  137. /// </summary>
  138. public void Init()
  139. {
  140. mConfigArray[(int)XmdsSkillDataKey.DmgRate] = CreateSkillValue(DmgRate);
  141. mConfigArray[(int)XmdsSkillDataKey.CDTime] = CreateSkillValue(CDTime);
  142. mConfigArray[(int)XmdsSkillDataKey.canAuto] = CreateSkillValue(canAuto);
  143. if(this.TalentData != null && this.TalentData.Length > 0)
  144. {
  145. mConfigArray[(int)XmdsSkillDataKey.TalentData] = CreateSkillValue(TalentData);
  146. }
  147. if (this.ValueSet != null && this.ValueSet.Length > 0)
  148. {
  149. mConfigArray[(int)XmdsSkillDataKey.ValueSet] = CreateSkillValue(ValueSet);
  150. }
  151. if (this.ValueSet2 != null && this.ValueSet2.Length > 0)
  152. {
  153. mConfigArray[(int)XmdsSkillDataKey.ValueSet2] = CreateSkillValue(ValueSet2);
  154. }
  155. if (this.ValueSet3 != null && this.ValueSet3.Length > 0)
  156. {
  157. mConfigArray[(int)XmdsSkillDataKey.ValueSet3] = CreateSkillValue(ValueSet3);
  158. }
  159. if (this.ValueSet4 != null && this.ValueSet4.Length > 0)
  160. {
  161. mConfigArray[(int)XmdsSkillDataKey.ValueSet4] = CreateSkillValue(ValueSet4);
  162. }
  163. //额外数值
  164. if (this.ValueSet5 != null && this.ValueSet5.Length > 0)
  165. {
  166. mConfigArray[(int)XmdsSkillDataKey.ValueSet5] = CreateSkillValue(ValueSet5);
  167. }
  168. //额外数值
  169. if (this.ValueSet6 != null && this.ValueSet6.Length > 0)
  170. {
  171. mConfigArray[(int)XmdsSkillDataKey.ValueSet6] = CreateSkillValue(ValueSet6);
  172. }
  173. //额外数值
  174. if (this.ValueSet7 != null && this.ValueSet7.Length > 0)
  175. {
  176. mConfigArray[(int)XmdsSkillDataKey.ValueSet7] = CreateSkillValue(ValueSet7);
  177. }
  178. //额外数值
  179. if (this.ValueSet8 != null && this.ValueSet8.Length > 0)
  180. {
  181. mConfigArray[(int)XmdsSkillDataKey.ValueSet8] = CreateSkillValue(ValueSet8);
  182. }
  183. }
  184. private XmdsSkillValue CreateSkillValue(string content)
  185. {
  186. XmdsSkillValue ret = null;
  187. ret = ParserContent(SkillID, content);
  188. return ret;
  189. }
  190. private XmdsSkillValue ParserContent(int id, string content)
  191. {
  192. XmdsSkillValue ret = null;
  193. try
  194. {
  195. if (!string.IsNullOrEmpty(content))
  196. {
  197. List<int> mValueMin = null;
  198. if (content.Contains(":"))
  199. {
  200. mValueMin = new List<int>();
  201. //截取;所得的数组.
  202. string[] strArray = null;
  203. if (content.Contains(";"))
  204. {
  205. strArray = content.Split(';');
  206. }
  207. else
  208. {
  209. strArray = new String[1];
  210. strArray[0] = content;
  211. }
  212. //截取:所得到的数组.
  213. string[] subArray = null;
  214. //完整数据已字符串形式存储.
  215. string[] ValueArray = new string[strArray.Length];
  216. //[1:34][2:55]或[3:44-55].
  217. for (int i = 0; i < strArray.Length; i++)
  218. {
  219. subArray = strArray[i].Split(':');
  220. if (subArray != null && subArray.Length == 2)
  221. {
  222. ValueArray[i] = subArray[1];
  223. }
  224. }
  225. //[34,34-44]
  226. if (ValueArray[0].Contains("-"))
  227. {
  228. string[] subArray2;
  229. List<int> mValueMax = new List<int>();
  230. int t = 0;
  231. for (int k = 0; k < ValueArray.Length; k++)
  232. {
  233. subArray2 = ValueArray[k].Split(',');
  234. t = Int32.Parse(subArray2[0]);
  235. mValueMin.Add(t);
  236. t = Int32.Parse(subArray2[1]);
  237. mValueMax.Add(t);
  238. XmdsSkillValue_DoubleArray temp = new XmdsSkillValue_DoubleArray(content);
  239. temp.SetValue(mValueMin, mValueMax);
  240. ret = temp;
  241. }
  242. }
  243. else if (ValueArray[0].Contains("_"))
  244. {
  245. if (ValueArray[0].Contains(","))
  246. {
  247. string[] subArray2;
  248. XmdsSkillValue_ListExt temp = new XmdsSkillValue_ListExt(content);
  249. List<IntIntData> tempArray = new List<IntIntData>();
  250. for (int k = 0; k < ValueArray.Length;)
  251. {
  252. subArray2 = ValueArray[k].Split(',');
  253. for (int l = 0; l < subArray2.Length; l++)
  254. {
  255. string[] subArray3 = subArray2[l].Split('_');
  256. tempArray.Add(new IntIntData(Int32.Parse(subArray3[0]), Int32.Parse(subArray3[1])));
  257. }
  258. temp.SetValue(tempArray);
  259. if (++k < ValueArray.Length)
  260. {
  261. tempArray = new List<IntIntData>();
  262. }
  263. }
  264. ret = temp;
  265. }
  266. else
  267. {
  268. XmdsSkillValueExt temp = new XmdsSkillValueExt(content);
  269. List<IntIntData> tempArray = new List<IntIntData>();
  270. for (int k = 0; k < ValueArray.Length; k++)
  271. {
  272. string[] subArray2 = ValueArray[k].Split('_');
  273. tempArray.Add(new IntIntData(Int32.Parse(subArray2[0]), Int32.Parse(subArray2[1])));
  274. }
  275. temp.SetValue(tempArray);
  276. ret = temp;
  277. }
  278. }
  279. else if(ValueArray[0].Contains(","))
  280. {
  281. string[] subArray2;
  282. XmdsSkillValue_List temp = new XmdsSkillValue_List(content);
  283. for (int k = 0; k < ValueArray.Length;)
  284. {
  285. subArray2 = ValueArray[k].Split(',');
  286. for(int l = 0; l < subArray2.Length; l++)
  287. {
  288. mValueMin.Add(Int32.Parse(subArray2[l]));
  289. }
  290. temp.SetValue(mValueMin);
  291. if(++k < ValueArray.Length)
  292. {
  293. mValueMin = new List<int>();
  294. }
  295. }
  296. ret = temp;
  297. }
  298. else
  299. {
  300. for (int k = 0; k < ValueArray.Length; k++)
  301. {
  302. mValueMin.Add(Int32.Parse(ValueArray[k]));
  303. }
  304. XmdsSkillValue_Array temp = new XmdsSkillValue_Array(content);
  305. temp.SetValue(mValueMin);
  306. ret = temp;
  307. }
  308. }
  309. else if(content.Contains(","))
  310. {
  311. XmdsSkillValue_Array temp = new XmdsSkillValue_Array(content);
  312. String [] subArray = content.Split(',');
  313. mValueMin = new List<int>();
  314. for (int l = 0; l < subArray.Length; l++)
  315. {
  316. mValueMin.Add(Int32.Parse(subArray[l]));
  317. }
  318. temp.SetValue(mValueMin);
  319. ret = temp;
  320. }
  321. else if (content.Contains("_"))
  322. {
  323. XmdsSkillValue_Array temp = new XmdsSkillValue_Array(content);
  324. String[] subArray = content.Split('_');
  325. mValueMin = new List<int>();
  326. for (int l = 0; l < subArray.Length; l++)
  327. {
  328. mValueMin.Add(Int32.Parse(subArray[l]));
  329. }
  330. temp.SetValue(mValueMin);
  331. ret = temp;
  332. }
  333. else
  334. {
  335. int v = Int32.Parse(content);
  336. ret = new XmdsSkillValue(content, false);
  337. ret.SetValue(v);
  338. }
  339. }
  340. }
  341. catch (Exception error)
  342. {
  343. throw new Exception(string.Format("技能 {0} 数据 {1} 解析错误:{2}", id, content, error.ToString()));
  344. }
  345. return ret;
  346. }
  347. }
  348. public class IntIntData
  349. {
  350. public int value1;
  351. public int value2;
  352. public IntIntData() { }
  353. public IntIntData(int value1, int value2)
  354. {
  355. this.value1 = value1;
  356. this.value2 = value2;
  357. }
  358. public void ReSet()
  359. {
  360. this.value1 = 0;
  361. this.value2 = 0;
  362. }
  363. }
  364. public class XmdsSkillValue
  365. {
  366. public static readonly XmdsSkillValue Default = new XmdsSkillValue("", false) { mValue = 0};
  367. protected string mContent = null;
  368. private bool mSingleCfg = true;
  369. private int mValue;
  370. public XmdsSkillValue(string content, bool subClass = true)
  371. {
  372. mContent = content;
  373. if (subClass)
  374. {
  375. mSingleCfg = false;
  376. }
  377. }
  378. public virtual int GetValue()
  379. {
  380. return mValue;
  381. }
  382. public bool IsSingleCfg()
  383. {
  384. return this.mSingleCfg;
  385. }
  386. public virtual int GetValue(int lv)
  387. {
  388. return mValue;
  389. }
  390. public virtual int GetValueExt(int lv)
  391. {
  392. return mValue;
  393. }
  394. public virtual int GetValue(int lv, int ext)
  395. {
  396. return mValue;
  397. }
  398. public virtual int GetValueExt(int lv, int ext)
  399. {
  400. return mValue;
  401. }
  402. internal void SetValue(int v)
  403. {
  404. mValue = v;
  405. }
  406. //[1->N]
  407. protected bool IsValid(int lv, int listCount)
  408. {
  409. if (0 < lv && lv <= listCount)
  410. {
  411. return true;
  412. }
  413. return false;
  414. }
  415. }
  416. public class XmdsSkillValueExt : XmdsSkillValue
  417. {
  418. protected List<IntIntData> mList = null;
  419. public XmdsSkillValueExt(string content) : base(content)
  420. {
  421. mContent = content;
  422. }
  423. internal void SetValue(List<IntIntData> list)
  424. {
  425. mList = list;
  426. }
  427. public override int GetValue(int lv)
  428. {
  429. //验证等级有效性.
  430. int k = 0;
  431. if (IsValid(lv, mList.Count))
  432. {
  433. k = lv - 1;
  434. }
  435. //else
  436. //{
  437. // XmdsBattleHelper.LogWarn(string.Format("XmdsSkillValue_Array get Value Error:skillcontent = {0}, lv = {1}", mContent, lv));
  438. //string stackInfo = new StackTrace().ToString();
  439. //XmdsBattleHelper.LogWarn("stackInfo : " + stackInfo);
  440. //}
  441. return mList[k].value1;
  442. }
  443. public override int GetValueExt(int lv)
  444. {
  445. //验证等级有效性.
  446. int k = 0;
  447. if (IsValid(lv, mList.Count))
  448. {
  449. k = lv - 1;
  450. }
  451. //else
  452. //{
  453. // XmdsBattleHelper.LogWarn(string.Format("XmdsSkillValue_Array get Value Error:skillcontent = {0}, lv = {1}", mContent, lv));
  454. //string stackInfo = new StackTrace().ToString();
  455. //XmdsBattleHelper.LogWarn("stackInfo : " + stackInfo);
  456. //}
  457. return mList[k].value2;
  458. }
  459. }
  460. public class XmdsSkillValue_Array : XmdsSkillValue
  461. {
  462. protected List<int> mMinList = null;
  463. public XmdsSkillValue_Array(string content) : base(content)
  464. {
  465. }
  466. internal void SetValue(List<int> list)
  467. {
  468. mMinList = list;
  469. if (mMinList == null || mMinList.Count == 0)
  470. {
  471. throw new Exception("无效的XmdsSkillValue_Array数据.");
  472. }
  473. }
  474. public override int GetValue(int lv)
  475. {
  476. //验证等级有效性.
  477. int k = 0;
  478. if(IsValid(lv, mMinList.Count))
  479. {
  480. k = lv - 1;
  481. }
  482. //else
  483. //{
  484. // XmdsBattleHelper.LogWarn(string.Format("XmdsSkillValue_Array get Value Error:skillcontent = {0}, lv = {1}", mContent, lv));
  485. //string stackInfo = new StackTrace().ToString();
  486. //XmdsBattleHelper.LogWarn("stackInfo : " + stackInfo);
  487. //}
  488. return mMinList[k];
  489. }
  490. }
  491. public class XmdsSkillValue_DoubleArray : XmdsSkillValue_Array
  492. {
  493. private static Random mRandom = new Random();
  494. protected List<int> mMaxList = null;
  495. public XmdsSkillValue_DoubleArray(string content) : base(content)
  496. {
  497. }
  498. internal void SetValue(List<int> minList, List<int> maxList)
  499. {
  500. mMinList = minList;
  501. mMaxList = maxList;
  502. if (mMinList == null || mMinList.Count == 0 || mMaxList == null || mMaxList.Count == 0 || mMinList.Count != mMaxList.Count)
  503. {
  504. throw new Exception("无效的XmdsSkillValue_DoubleArray数据.");
  505. }
  506. }
  507. public override int GetValue(int lv)
  508. {
  509. //验证等级有效性.
  510. int k = 0;
  511. if (IsValid(lv, mMinList.Count) || IsValid(lv, mMaxList.Count))
  512. {
  513. k = lv - 1;
  514. }
  515. else
  516. {
  517. XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_DoubleArray get Value Error:skillcontent = {0}", mContent));
  518. }
  519. int a = mMinList[k];
  520. int b = mMaxList[k];
  521. return mRandom.Next(a, b);
  522. }
  523. }
  524. public class XmdsSkillValue_List : XmdsSkillValue
  525. {
  526. protected List<List<int>> mList = null;
  527. public XmdsSkillValue_List(string content) : base(content)
  528. {
  529. mList = new List<List<int>>();
  530. }
  531. internal void SetValue(List<int> list)
  532. {
  533. if (list == null || list.Count == 0)
  534. {
  535. throw new Exception("无效的XmdsSkillValue_Array数据.");
  536. }
  537. else
  538. {
  539. mList.Add(list);
  540. }
  541. }
  542. public override int GetValue(int lv, int ext)
  543. {
  544. int k = 0;
  545. if(IsValid(lv, mList.Count))
  546. {
  547. k = lv - 1;
  548. }
  549. List<int> tempArray = mList[k];
  550. if(IsValid(ext, tempArray.Count))
  551. {
  552. return tempArray[ext-1];
  553. }
  554. else if(tempArray.Count > 0)
  555. {
  556. string stackInfo = new StackTrace().ToString();
  557. XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_List1 get Value Error:skillcontent = {0}访问lv,ext: {1}, {2}", mContent, lv, ext +
  558. ", stack: " + stackInfo));
  559. return tempArray[0];
  560. }
  561. XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_List2 get Value Error:skillcontent = {0}", mContent));
  562. return 0;
  563. }
  564. }
  565. public class XmdsSkillValue_ListExt : XmdsSkillValue
  566. {
  567. protected List<List<IntIntData>> mList = null;
  568. public XmdsSkillValue_ListExt(string content) : base(content)
  569. {
  570. mList = new List<List<IntIntData>>();
  571. }
  572. internal void SetValue(List<IntIntData> list)
  573. {
  574. if (list == null || list.Count == 0)
  575. {
  576. throw new Exception("无效的XmdsSkillValue_Array数据.");
  577. }
  578. else
  579. {
  580. mList.Add(list);
  581. }
  582. }
  583. public override int GetValue(int lv, int ext)
  584. {
  585. int k = 0;
  586. if (IsValid(lv, mList.Count))
  587. {
  588. k = lv - 1;
  589. }
  590. List<IntIntData> tempArray = mList[k];
  591. if (IsValid(ext, tempArray.Count))
  592. {
  593. return tempArray[ext - 1].value1;
  594. }
  595. else if (tempArray.Count > 0)
  596. {
  597. string stackInfo = new StackTrace().ToString();
  598. XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_ListExt 1 get Value Error:skillcontent = {0}@{1}@{2}@{3}", mContent, lv, ext, stackInfo));
  599. return tempArray[0].value1;
  600. }
  601. else
  602. {
  603. string stackInfo = new StackTrace().ToString();
  604. XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_ListExt 2 get Value Error:skillcontent = {0}@{1}@{2}@{3}", mContent, lv, ext, stackInfo));
  605. return 0;
  606. }
  607. }
  608. public override int GetValueExt(int lv, int ext)
  609. {
  610. int k = 0;
  611. if (IsValid(lv, mList.Count))
  612. {
  613. k = lv - 1;
  614. }
  615. List<IntIntData> tempArray = mList[k];
  616. if (IsValid(ext, tempArray.Count))
  617. {
  618. return tempArray[ext - 1].value2;
  619. }
  620. else if (tempArray.Count > 0)
  621. {
  622. string stackInfo = new StackTrace().ToString();
  623. XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_ListExt 3 get Value Error:skillcontent = {0},{1},{2},{3}", mContent, lv, ext, stackInfo));
  624. return tempArray[0].value2;
  625. }
  626. else
  627. {
  628. string stackInfo = new StackTrace().ToString();
  629. XmdsBattleHelper.LogError(string.Format("XmdsSkillValue_ListExt 4 get Value Error:skillcontent = {0},{1},{2},{3}", mContent, lv, ext, stackInfo));
  630. return 0;
  631. }
  632. }
  633. }
  634. }