SkillAsset.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using OfficeOpenXml;
  5. using Mono.Xml;
  6. using System.Security;
  7. public class EffectAsset
  8. {
  9. public int id;
  10. public string desc;
  11. public string effect;
  12. public string link;
  13. public int followType;
  14. public int targetType;
  15. public Vector3 rot;
  16. public float lifeTime;
  17. public static EffectAsset CreateEffectAsset(ExcelWorksheet sheet, int row)
  18. {
  19. EffectAsset effect = new EffectAsset();
  20. int col = 1;
  21. effect.id = sheet.GetValue<int>(row, col++);
  22. effect.desc = sheet.GetValue<string>(row, col++);
  23. effect.effect = sheet.GetValue<string>(row, col++);
  24. effect.link = sheet.GetValue<string>(row, col++);
  25. effect.followType = sheet.GetValue<int>(row, col++);
  26. effect.targetType = sheet.GetValue<int>(row, col++);
  27. effect.rot = StringUtil.convertVector3(sheet.GetValue<string>(row, col++));
  28. effect.lifeTime = sheet.GetValue<float>(row, col++);
  29. return effect;
  30. }
  31. public void SaveAssetToExcel(ref ExcelWorksheet sheet, int row)
  32. {
  33. if (sheet == null) return;
  34. int col = 1;
  35. sheet.SetValue(row, col++, this.id);
  36. sheet.SetValue(row, col++, this.desc);
  37. sheet.SetValue(row, col++, this.effect);
  38. sheet.SetValue(row, col++, this.link);
  39. sheet.SetValue(row, col++, this.followType);
  40. sheet.SetValue(row, col++, this.targetType);
  41. sheet.SetValue(row, col++, StringUtil.ConvertVector2Str(this.rot));
  42. sheet.SetValue(row, col++, this.lifeTime);
  43. }
  44. }
  45. public class FunctionDataAsset
  46. {
  47. public int id;
  48. public string name;
  49. public BattleBuffType buffType;
  50. public Buff_Function_Type functionType;
  51. public int group;
  52. public bool canHurtStop; //是否可以伤害打断
  53. public bool forbidMove; //是否影响动作
  54. public bool forbidNormalAttack; //禁止普攻
  55. public bool forbidSkill; //禁止技能释放
  56. public bool canIgnoreDodge; //是否可以闪避
  57. public string desc;
  58. public float intervalTime; //间隔时长
  59. public int fromAttr; //来源属性
  60. public string icon; //图标
  61. public int effectId; //特效id
  62. public string word; //文字
  63. public int iconIdx = -1;
  64. public int wordIdx = -1;
  65. public int effectIdx = -1;
  66. public static FunctionDataAsset CreateFunAsset(ExcelWorksheet sheet, int row)
  67. {
  68. FunctionDataAsset funAsset = new FunctionDataAsset();
  69. int col = 1;
  70. funAsset.id = sheet.GetValue<int>(row, col++);
  71. funAsset.name = sheet.GetValue<string>(row, col++);
  72. funAsset.functionType = (Buff_Function_Type)(sheet.GetValue<int>(row, col++));
  73. funAsset.group = sheet.GetValue<int>(row, col++);
  74. funAsset.buffType = (BattleBuffType)(sheet.GetValue<int>(row, col++));
  75. funAsset.canHurtStop = sheet.GetValue<int>(row, col++) > 0 ? true : false;
  76. funAsset.forbidMove = sheet.GetValue<int>(row, col++) > 0 ? true : false;
  77. funAsset.forbidNormalAttack = sheet.GetValue<int>(row, col++) > 0 ? true : false;
  78. funAsset.forbidSkill = sheet.GetValue<int>(row, col++) > 0 ? true : false;
  79. funAsset.canIgnoreDodge = sheet.GetValue<int>(row, col++) > 0 ? true : false;
  80. funAsset.desc = sheet.GetValue<string>(row, col++);
  81. funAsset.icon = sheet.GetValue<string>(row, col++);
  82. string temp = sheet.GetValue<string>(row, col++);
  83. int.TryParse(temp, out funAsset.effectId);
  84. funAsset.word = sheet.GetValue<string>(row, col++);
  85. return funAsset;
  86. }
  87. public void SaveAssetToExcel(ref ExcelWorksheet sheet, int row)
  88. {
  89. if (sheet == null) return;
  90. int col = 1;
  91. sheet.SetValue(row, col++, this.id);
  92. sheet.SetValue(row, col++, this.name);
  93. sheet.SetValue(row, col++, (int)this.functionType);
  94. sheet.SetValue(row, col++, this.group);
  95. sheet.SetValue(row, col++, (int)this.buffType);
  96. sheet.SetValue(row, col++, this.canHurtStop ? 1 : 0);
  97. sheet.SetValue(row, col++, this.forbidMove?1:0);
  98. sheet.SetValue(row, col++, this.forbidNormalAttack?1:0);
  99. sheet.SetValue(row, col++, this.forbidSkill ? 1 : 0);
  100. sheet.SetValue(row, col++, this.canIgnoreDodge ? 1 : 0);
  101. sheet.SetValue(row, col++, this.desc);
  102. sheet.SetValue(row, col++, this.icon);
  103. sheet.SetValue(row, col++, this.effectId);
  104. sheet.SetValue(row, col++, this.word);
  105. }
  106. public void Copy(FunctionDataAsset from)
  107. {
  108. if (from == null) return;
  109. this.id = from.id;
  110. this.name = from.name;
  111. this.buffType = from.buffType;
  112. this.functionType = from.functionType;
  113. this.group = from.group;
  114. this.canHurtStop = from.canHurtStop;
  115. this.forbidMove = from.forbidMove;
  116. this.forbidNormalAttack = from.forbidNormalAttack;
  117. this.forbidSkill = from.forbidSkill;
  118. this.canIgnoreDodge = from.canIgnoreDodge;
  119. this.desc = from.desc;
  120. this.intervalTime = from.intervalTime;
  121. this.fromAttr = from.fromAttr;
  122. this.icon = from.icon;
  123. this.effectId = from.effectId;
  124. this.word = from.word;
  125. this.iconIdx = from.iconIdx;
  126. this.wordIdx = from.wordIdx;
  127. this.effectIdx = from.effectIdx;
  128. }
  129. }
  130. public class FrameEventParamEditor
  131. {
  132. public string name;
  133. public string val;
  134. public string valType;
  135. public int valTypeIdx = -1;
  136. public int valIdx = -1;
  137. public SecurityElement SaveCfgToXml()
  138. {
  139. SecurityElement paramNode = new SecurityElement("param");
  140. paramNode.AddAttribute("name", this.name);
  141. paramNode.AddAttribute("value", this.val);
  142. paramNode.AddAttribute("valueType", this.valType);
  143. return paramNode;
  144. }
  145. }
  146. public class ActionEventParamEditor
  147. {
  148. public int startFrame;
  149. public int endFrame;
  150. public int eventType;
  151. public string desc;
  152. public bool bAffectBySing;
  153. public List<FrameEventParamEditor> frameParams;
  154. public ActionEventParamEditor()
  155. {
  156. }
  157. public ActionEventParamEditor(ActionEventParamEditor src)
  158. {
  159. if(src!=null)
  160. {
  161. this.startFrame = src.startFrame;
  162. this.endFrame = src.endFrame;
  163. this.eventType = src.eventType;
  164. this.desc = src.desc;
  165. this.bAffectBySing = src.bAffectBySing;
  166. if (this.frameParams == null)
  167. this.frameParams = new List<FrameEventParamEditor>();
  168. this.frameParams.Clear();
  169. if (src.frameParams != null)
  170. this.frameParams.AddRange(src.frameParams);
  171. }
  172. }
  173. public SecurityElement SaveCfgToXml()
  174. {
  175. SecurityElement eventNode = new SecurityElement("event");
  176. eventNode.AddAttribute("startFrame", this.startFrame.ToString());
  177. eventNode.AddAttribute("endFrame", this.endFrame.ToString());
  178. eventNode.AddAttribute("type", this.eventType.ToString());
  179. eventNode.AddAttribute("affectBySing", this.bAffectBySing.ToString());
  180. eventNode.AddAttribute("desc", this.desc);
  181. if(this.frameParams != null)
  182. {
  183. for(int idx =0; idx < this.frameParams.Count;idx++)
  184. {
  185. FrameEventParamEditor paramData = this.frameParams[idx];
  186. if (string.IsNullOrEmpty(paramData.val) || string.IsNullOrEmpty(paramData.valType) || string.IsNullOrEmpty(paramData.name)) continue;
  187. SecurityElement paramNode = paramData.SaveCfgToXml();
  188. eventNode.AddChild(paramNode);
  189. }
  190. }
  191. return eventNode;
  192. }
  193. }
  194. public class ActionEventDataEditor
  195. {
  196. private int mId;
  197. public int Id
  198. {
  199. get { return mId; }
  200. }
  201. public string Name
  202. {
  203. get;set;
  204. }
  205. private int mTotalFrame = 0;
  206. public int TotalFrame
  207. {
  208. get { return mTotalFrame; }
  209. set
  210. {
  211. mTotalFrame = value;
  212. }
  213. }
  214. /// <summary>
  215. /// 性别
  216. /// </summary>
  217. private int mGender = 2;
  218. public int Gender
  219. {
  220. get { return mGender; }
  221. set { mGender = value; }
  222. }
  223. public List<ActionEventParamEditor> ActionEventList
  224. {
  225. get; private set;
  226. }
  227. public ActionEventDataEditor(int id, int totalFrame,string name,int gender)
  228. {
  229. this.mId = id;
  230. this.mTotalFrame = totalFrame;
  231. this.Name = name;
  232. this.mGender = gender;
  233. }
  234. public void AddEvent(ActionEventParamEditor eve)
  235. {
  236. if (ActionEventList == null)
  237. {
  238. ActionEventList = new List<ActionEventParamEditor>();
  239. }
  240. ActionEventList.Add(eve);
  241. }
  242. }
  243. public class FunctionValData
  244. {
  245. public int funId;
  246. public float val; //初始值
  247. public float incVal; //随等级变化值
  248. public float duration; //初始时长
  249. public float incDuration; //随等级变化时长
  250. public int fromAttr; //依赖那个属性进行计算
  251. public float intervalTime; //间隔时间
  252. public bool extendFold;
  253. public FunctionValData(int id, float val, float incVal, float dur, float incDur, int fromAttr, float intervalTime)
  254. {
  255. this.funId = id;
  256. this.val = val;
  257. this.incVal = incVal;
  258. this.duration = dur;
  259. this.incDuration = incDur;
  260. this.fromAttr = fromAttr;
  261. this.intervalTime = intervalTime;
  262. this.extendFold = true;
  263. }
  264. public FunctionValData(FunctionValData src)
  265. {
  266. if(src != null)
  267. {
  268. this.funId = src.funId;
  269. this.val = src.val;
  270. this.incVal = src.incVal;
  271. this.duration = src.duration;
  272. this.incDuration = src.duration;
  273. this.fromAttr = src.fromAttr;
  274. this.intervalTime = src.intervalTime;
  275. }
  276. }
  277. public override string ToString()
  278. {
  279. return funId + ":" + val + (incVal > 0 ? ("_" + incVal) : "") + ":" + duration + (incDuration > 0 ? ("_" + incDuration) : "") + ":" + fromAttr + ":" + intervalTime;
  280. }
  281. public void Apply(FunctionValData src)
  282. {
  283. if (src != null)
  284. {
  285. this.funId = src.funId;
  286. this.val = src.val;
  287. this.incVal = src.incVal;
  288. this.duration = src.duration;
  289. this.incDuration = src.duration;
  290. this.fromAttr = src.fromAttr;
  291. this.intervalTime = src.intervalTime;
  292. }
  293. }
  294. }
  295. public class BuffDataAsset
  296. {
  297. public int id;
  298. public string desc;
  299. public string extendFuns;
  300. public int damageType; //伤害类型
  301. public int targetType; //目标类型
  302. public int hitType; //命中类型
  303. public int effectiveness; //生效率
  304. public bool ignoreMultiHurt; //是否忽略多段伤害
  305. public bool removeFunWhenStop; //buff移除时是否关闭对应的fun
  306. public List<FunctionValData> funList;
  307. public ActionEventDataEditor actionEventData;
  308. public ActionEventDataEditor femaleActionEventData;
  309. public bool canPerfectDodge = false;
  310. public bool canDodge = false;
  311. public bool canResist = false;
  312. public bool canCrit = false;
  313. #region 工具中使用的东西
  314. public bool extendBaseFold = true;
  315. public bool extendFunFold = true;
  316. public bool extendFrameEventFold = true;
  317. public bool extendFemaleFrameEventFold = false;
  318. public bool extendModelPrefab = true;
  319. public Vector2 scrollPos = Vector2.zero;
  320. public RuntimeAnimatorController modelAnimator = null;
  321. public UnityEditor.Animations.AnimatorStateMachine stateMachine = null;
  322. public string[] animClipNames = null;
  323. public int animClipIdx = -1;
  324. #endregion
  325. public static BuffDataAsset CreateBuffAsset(ExcelWorksheet sheet,int row)
  326. {
  327. BuffDataAsset buffAsset = new BuffDataAsset();
  328. int col = 1;
  329. buffAsset.id = sheet.GetValue<int>(row, col++);
  330. buffAsset.desc = sheet.GetValue<string>(row, col++);
  331. string funStr = sheet.GetValue<string>(row, col++);
  332. if(!string.IsNullOrEmpty(funStr))
  333. {
  334. string[] funStrList = funStr.Split(';');
  335. buffAsset.funList = new List<FunctionValData>(funStrList.Length);
  336. for (int idx = 0; idx < funStrList.Length; idx++)
  337. {
  338. string[] funTemp = funStrList[idx].Split(':');
  339. if (funTemp.Length < 2) continue;
  340. int funId = 0;
  341. float funVal = 0;
  342. float funIncVal = 0;
  343. float funDuration = 0;
  344. float funIncDuration = 0;
  345. int fromAttr = 0;
  346. float intervalTime = 0;
  347. if (funTemp.Length > 1)
  348. {
  349. float[] funValList = StringUtil.split2Float(funTemp[1], '_');
  350. if (funValList.Length > 0)
  351. funVal = funValList[0];
  352. if (funValList.Length > 1)
  353. funIncVal = funValList[1];
  354. }
  355. if (funTemp.Length > 2)
  356. {
  357. float[] funDurList = StringUtil.split2Float(funTemp[2], '_');
  358. if (funDurList.Length > 0)
  359. funDuration = funDurList[0];
  360. if (funDurList.Length > 1)
  361. funIncDuration = funDurList[1];
  362. }
  363. if (funTemp.Length > 3)
  364. {
  365. int.TryParse(funTemp[3], out fromAttr);
  366. }
  367. if (funTemp.Length > 4)
  368. {
  369. float.TryParse(funTemp[4], out intervalTime);
  370. }
  371. if (int.TryParse(funTemp[0], out funId))
  372. {
  373. FunctionValData fun = new FunctionValData(funId, funVal, funIncVal, funDuration, funIncDuration, fromAttr, intervalTime);
  374. buffAsset.funList.Add(fun);
  375. }
  376. }
  377. }
  378. buffAsset.extendFuns = sheet.GetValue<string>(row, col++);
  379. buffAsset.damageType = sheet.GetValue<int>(row, col++);
  380. buffAsset.targetType = sheet.GetValue<int>(row, col++);
  381. buffAsset.hitType = sheet.GetValue<int>(row, col++);
  382. buffAsset.effectiveness = sheet.GetValue<int>(row, col++);
  383. buffAsset.ignoreMultiHurt = sheet.GetValue<int>(row, col++) > 0 ? true : false;
  384. buffAsset.removeFunWhenStop = sheet.GetValue<int>(row, col++) > 0 ? true : false;
  385. buffAsset.canPerfectDodge = (buffAsset.hitType & (int)BuffHitType.Perfect_Dodge) == (int)BuffHitType.Perfect_Dodge;
  386. buffAsset.canDodge = (buffAsset.hitType & (int)BuffHitType.Dodge) == (int)BuffHitType.Dodge;
  387. buffAsset.canResist = (buffAsset.hitType & (int)BuffHitType.Resist) == (int)BuffHitType.Resist;
  388. buffAsset.canCrit = (buffAsset.hitType & (int)BuffHitType.Critical) == (int)BuffHitType.Critical;
  389. return buffAsset;
  390. }
  391. public BuffDataAsset()
  392. {
  393. }
  394. public BuffDataAsset(int buffId)
  395. {
  396. this.id = buffId;
  397. }
  398. public void Copy(BuffDataAsset src)
  399. {
  400. if (src == null) return;
  401. this.id = src.id;
  402. this.desc = src.desc;
  403. this.extendFuns = src.extendFuns;
  404. this.damageType = src.damageType;
  405. this.targetType = src.targetType;
  406. this.hitType = src.hitType;
  407. this.effectiveness = src.effectiveness;
  408. this.ignoreMultiHurt = src.ignoreMultiHurt;
  409. this.removeFunWhenStop = src.removeFunWhenStop;
  410. this.canPerfectDodge = src.canPerfectDodge;
  411. this.canDodge = src.canDodge;
  412. this.canResist = src.canResist;
  413. this.canCrit = src.canCrit;
  414. this.actionEventData = src.actionEventData;
  415. this.femaleActionEventData = src.femaleActionEventData;
  416. if (this.funList == null)
  417. this.funList = new List<FunctionValData>();
  418. this.funList.Clear();
  419. if(src.funList != null && src.funList.Count > 0)
  420. {
  421. for(int idx = 0; idx < src.funList.Count;idx++)
  422. {
  423. this.funList.Add(new FunctionValData(src.funList[idx]));
  424. }
  425. }
  426. }
  427. public void Apply(BuffDataAsset src)
  428. {
  429. if (src == null) return;
  430. this.id = src.id;
  431. this.desc = src.desc;
  432. this.extendFuns = src.extendFuns;
  433. this.damageType = src.damageType;
  434. this.targetType = src.targetType;
  435. this.hitType = src.hitType;
  436. this.effectiveness = src.effectiveness;
  437. this.ignoreMultiHurt = src.ignoreMultiHurt;
  438. this.removeFunWhenStop = src.removeFunWhenStop;
  439. this.canPerfectDodge = src.canPerfectDodge;
  440. this.canDodge = src.canDodge;
  441. this.canResist = src.canResist;
  442. this.canCrit = src.canCrit;
  443. this.actionEventData = src.actionEventData;
  444. this.femaleActionEventData = src.femaleActionEventData;
  445. if (src.funList != null && src.funList.Count > 0)
  446. {
  447. for (int idx = 0; idx < src.funList.Count; idx++)
  448. {
  449. FunctionValData funVal = GetFunData(src.funList[idx].funId);
  450. if(funVal == null)
  451. {
  452. funVal = new FunctionValData(src.funList[idx]);
  453. this.funList.Add(funVal);
  454. }
  455. else
  456. {
  457. funVal.Apply(src.funList[idx]);
  458. }
  459. }
  460. }
  461. for(int idx = this.funList.Count-1; idx >= 0 ;idx--)
  462. {
  463. FunctionValData val = src.GetFunData(this.funList[idx].funId);
  464. if(val == null)
  465. {
  466. this.funList.RemoveAt(idx);
  467. }
  468. }
  469. }
  470. public FunctionValData GetFunData(int id)
  471. {
  472. if (funList == null) return null;
  473. for(int idx =0; idx < funList.Count;idx++)
  474. {
  475. if (funList[idx].funId == id) return funList[idx];
  476. }
  477. return null;
  478. }
  479. public void SaveAssetToExcel(ref ExcelWorksheet sheet, int row)
  480. {
  481. if (sheet == null) return;
  482. string funStr = "";
  483. if(funList != null)
  484. {
  485. for(int idx =0; idx < funList.Count;idx++)
  486. {
  487. FunctionValData val = funList[idx];
  488. if(idx == 0)
  489. {
  490. funStr = val.ToString();
  491. }
  492. else
  493. {
  494. funStr = funStr + ";" + val.ToString();
  495. }
  496. }
  497. }
  498. int col = 1;
  499. this.hitType = 0;
  500. if (this.canPerfectDodge)
  501. this.hitType |= (int)BuffHitType.Perfect_Dodge;
  502. if (this.canDodge)
  503. this.hitType |= (int)BuffHitType.Dodge;
  504. if (this.canResist)
  505. this.hitType |= (int)BuffHitType.Resist;
  506. if (this.canCrit)
  507. this.hitType |= (int)BuffHitType.Critical;
  508. sheet.SetValue(row, col++, this.id);
  509. sheet.SetValue(row, col++, this.desc);
  510. sheet.SetValue(row, col++, funStr);
  511. sheet.SetValue(row, col++, this.extendFuns);
  512. sheet.SetValue(row, col++, (int)this.damageType);
  513. sheet.SetValue(row, col++, (int)this.targetType);
  514. sheet.SetValue(row, col++, this.hitType);
  515. sheet.SetValue(row, col++, this.effectiveness);
  516. sheet.SetValue(row, col++, this.ignoreMultiHurt ? 1 : 0);
  517. sheet.SetValue(row, col++, this.removeFunWhenStop ? 1 : 0);
  518. }
  519. public SecurityElement SaveFrameEventToXml()
  520. {
  521. if (actionEventData == null) return null;
  522. SecurityElement buffNode = new SecurityElement("buff");
  523. buffNode.AddAttribute("id", this.actionEventData.Id.ToString());
  524. buffNode.AddAttribute("name", this.actionEventData.Name);
  525. buffNode.AddAttribute("endFrame", this.actionEventData.TotalFrame.ToString());
  526. buffNode.AddAttribute("gender", this.actionEventData.Gender.ToString());
  527. if(this.actionEventData.ActionEventList!=null)
  528. {
  529. for(int idx =0; idx < this.actionEventData.ActionEventList.Count;idx++)
  530. {
  531. ActionEventParamEditor eventData = this.actionEventData.ActionEventList[idx];
  532. SecurityElement eventNode = eventData.SaveCfgToXml();
  533. buffNode.AddChild(eventNode);
  534. }
  535. }
  536. return buffNode;
  537. }
  538. public SecurityElement SaveFemaleFrameEventToXml()
  539. {
  540. if (femaleActionEventData == null) return null;
  541. SecurityElement buffNode = new SecurityElement("buff");
  542. buffNode.AddAttribute("id", this.femaleActionEventData.Id.ToString());
  543. buffNode.AddAttribute("name", this.femaleActionEventData.Name);
  544. buffNode.AddAttribute("endFrame", this.femaleActionEventData.TotalFrame.ToString());
  545. buffNode.AddAttribute("gender", this.femaleActionEventData.Gender.ToString());
  546. if (this.femaleActionEventData.ActionEventList != null)
  547. {
  548. for (int idx = 0; idx < this.femaleActionEventData.ActionEventList.Count; idx++)
  549. {
  550. ActionEventParamEditor eventData = this.femaleActionEventData.ActionEventList[idx];
  551. SecurityElement eventNode = eventData.SaveCfgToXml();
  552. buffNode.AddChild(eventNode);
  553. }
  554. }
  555. return buffNode;
  556. }
  557. }
  558. public class SkillAsset
  559. {
  560. public int uniqueId;
  561. public int skillId;
  562. public int skillLv;
  563. public string skillName;
  564. public string skillDesc;
  565. public string skillIcon;
  566. public int skillType;
  567. public int cost;
  568. public int jobType;
  569. public int jobBranch;
  570. public int jobStage;
  571. public float fixedSingTime;
  572. public float changeSingTime;
  573. public float preCastingTime;
  574. public float castingTime;
  575. public float afterCastingTime;
  576. public float cd;
  577. public bool hide;
  578. public string levelUpDesc;
  579. public float[] PerceptionRange = new float[6];
  580. public List<int> buffIdList;
  581. public List<BuffDataAsset> buffList;
  582. public bool bAddNewBuff = false;
  583. public bool extendPerceptionFold = false;
  584. public bool extendBuffFold = true;
  585. public int iconIdx = -1;
  586. public SkillAsset()
  587. {
  588. this.skillId = 0;
  589. }
  590. public void AddNewBuff(BuffDataAsset buffData)
  591. {
  592. if (buffList == null)
  593. buffList = new List<BuffDataAsset>();
  594. buffList.Add(buffData);
  595. }
  596. public void RemoveBuff(BuffDataAsset buffData)
  597. {
  598. if (buffList == null || buffData == null) return;
  599. for(int idx =0; idx < buffList.Count;idx++)
  600. {
  601. if(buffList[idx].id == buffData.id)
  602. {
  603. buffList.RemoveAt(idx);
  604. return;
  605. }
  606. }
  607. }
  608. public BuffDataAsset GetBuffData(int buffId)
  609. {
  610. if (buffList == null) return null;
  611. for(int idx =0; idx < buffList.Count;idx++)
  612. {
  613. if (buffList[idx].id == buffId) return buffList[idx];
  614. }
  615. return null;
  616. }
  617. public void AddFunEventToBuff(int buffId, FunctionDataAsset funAsset)
  618. {
  619. BuffDataAsset buffData = GetBuffData(buffId);
  620. if (buffData == null) return;
  621. if (buffData.funList == null)
  622. buffData.funList = new List<FunctionValData>();
  623. FunctionValData newFunVal = new FunctionValData(funAsset.id, 0, 0, 0, 0, 0, 0);
  624. buffData.funList.Add(newFunVal);
  625. }
  626. public void Copy(SkillAsset src)
  627. {
  628. if (src == null) return;
  629. this.uniqueId = src.uniqueId;
  630. this.skillId = src.skillId;
  631. this.skillLv = src.skillLv;
  632. this.skillName = src.skillName;
  633. this.skillDesc = src.skillDesc;
  634. this.skillIcon = src.skillIcon;
  635. this.skillType = src.skillType;
  636. this.cost = src.cost;
  637. this.jobType = src.jobType;
  638. this.jobBranch = src.jobBranch;
  639. this.jobStage = src.jobStage;
  640. this.fixedSingTime = src.fixedSingTime;
  641. this.changeSingTime = src.changeSingTime;
  642. this.preCastingTime = src.preCastingTime;
  643. this.castingTime = src.castingTime;
  644. this.afterCastingTime = src.afterCastingTime;
  645. this.cd = src.cd;
  646. this.hide = src.hide;
  647. this.levelUpDesc = src.levelUpDesc;
  648. for (int idx = 0; idx < src.PerceptionRange.Length; idx++)
  649. this.PerceptionRange[idx] = src.PerceptionRange[idx];
  650. if (buffList == null)
  651. buffList = new List<BuffDataAsset>();
  652. buffList.Clear();
  653. if (src.buffList != null && src.buffList.Count > 0)
  654. {
  655. for(int idx =0; idx < src.buffList.Count;idx++)
  656. {
  657. BuffDataAsset srcBuffdata = src.buffList[idx];
  658. BuffDataAsset buff = new BuffDataAsset();
  659. buff.Copy(srcBuffdata);
  660. buffList.Add(buff);
  661. }
  662. }
  663. this.iconIdx = src.iconIdx;
  664. }
  665. public void Apply(SkillAsset src)
  666. {
  667. this.skillId = src.skillId;
  668. this.skillLv = src.skillLv;
  669. this.skillName = src.skillName;
  670. this.skillDesc = src.skillDesc;
  671. this.skillIcon = src.skillIcon;
  672. this.skillType = src.skillType;
  673. this.cost = src.cost;
  674. this.jobType = src.jobType;
  675. this.jobBranch = src.jobBranch;
  676. this.jobStage = src.jobStage;
  677. this.fixedSingTime = src.fixedSingTime;
  678. this.changeSingTime = src.changeSingTime;
  679. this.preCastingTime = src.preCastingTime;
  680. this.castingTime = src.castingTime;
  681. this.afterCastingTime = src.afterCastingTime;
  682. this.cd = src.cd;
  683. this.hide = src.hide;
  684. this.levelUpDesc = src.levelUpDesc;
  685. for (int idx = 0; idx < src.PerceptionRange.Length; idx++)
  686. this.PerceptionRange[idx] = src.PerceptionRange[idx];
  687. if (src.buffList != null && src.buffList.Count > 0)
  688. {
  689. for (int idx = 0; idx < src.buffList.Count; idx++)
  690. {
  691. BuffDataAsset srcBuff = src.buffList[idx];
  692. BuffDataAsset buff = GetBuffData(srcBuff.id);
  693. if(buff == null)
  694. {
  695. buff = new BuffDataAsset();
  696. buff.Copy(srcBuff);
  697. buffList.Add(buff);
  698. }
  699. else
  700. {
  701. buff.Apply(srcBuff);
  702. }
  703. }
  704. }
  705. for(int idx = buffList.Count -1; idx>=0; idx--)
  706. {
  707. BuffDataAsset buff = src.GetBuffData(buffList[idx].id);
  708. if(buff == null)
  709. {
  710. this.buffList.RemoveAt(idx);
  711. }
  712. }
  713. this.iconIdx = src.iconIdx;
  714. }
  715. public static SkillAsset CreateSkillAsset(ExcelWorksheet sheet,int rowIndex)
  716. {
  717. int colIndex = 1;
  718. SkillAsset skill = new SkillAsset();
  719. skill.uniqueId = sheet.GetValue<int>(rowIndex, colIndex++);
  720. skill.skillId = sheet.GetValue<int>(rowIndex, colIndex++);
  721. skill.skillName = sheet.GetValue<string>(rowIndex, colIndex++);
  722. skill.skillDesc = sheet.GetValue<string>(rowIndex, colIndex++);
  723. skill.skillIcon = sheet.GetValue<string>(rowIndex, colIndex++);
  724. skill.skillLv = sheet.GetValue<int>(rowIndex, colIndex++);
  725. skill.skillType = sheet.GetValue<int>(rowIndex, colIndex++);
  726. skill.cost = sheet.GetValue<int>(rowIndex, colIndex++);
  727. skill.jobType = sheet.GetValue<int>(rowIndex, colIndex++);
  728. skill.jobBranch = sheet.GetValue<int>(rowIndex, colIndex++);
  729. skill.jobStage = sheet.GetValue<int>(rowIndex, colIndex++);
  730. skill.fixedSingTime = sheet.GetValue<float>(rowIndex, colIndex++);
  731. skill.changeSingTime = sheet.GetValue<float>(rowIndex, colIndex++);
  732. skill.preCastingTime = sheet.GetValue<float>(rowIndex, colIndex++);
  733. skill.castingTime = sheet.GetValue<float>(rowIndex, colIndex++);
  734. skill.afterCastingTime = sheet.GetValue<float>(rowIndex, colIndex++);
  735. skill.cd = sheet.GetValue<float>(rowIndex, colIndex++);
  736. string buffStr = sheet.GetValue<string>(rowIndex, colIndex++);
  737. if (!string.IsNullOrEmpty(buffStr))
  738. {
  739. skill.buffIdList = StringUtil.convert2IntList(buffStr, ';');
  740. }
  741. for (int idx = 0; idx <= 5; idx++)
  742. {
  743. skill.PerceptionRange[idx] = sheet.GetValue<float>(rowIndex, colIndex++);
  744. }
  745. skill.hide = sheet.GetValue<int>(rowIndex, colIndex++) > 1 ? true : false;
  746. skill.levelUpDesc = sheet.GetValue<string>(rowIndex, colIndex++);
  747. return skill;
  748. }
  749. public void SaveAssetToExcel(ref ExcelWorksheet sheet, int row)
  750. {
  751. int col = 1;
  752. Debug.Log("skillId:" + this.skillId + " LV:" + this.skillLv);
  753. this.uniqueId = this.skillId * 100 + this.skillLv;
  754. sheet.SetValue(row, col++,this.uniqueId);
  755. sheet.SetValue(row, col++, this.skillId);
  756. sheet.SetValue(row, col++, this.skillName);
  757. sheet.SetValue(row, col++, this.skillDesc);
  758. sheet.SetValue(row, col++, this.skillIcon);
  759. sheet.SetValue(row, col++, this.skillLv);
  760. sheet.SetValue(row, col++, this.skillType);
  761. sheet.SetValue(row, col++, this.cost);
  762. sheet.SetValue(row, col++, this.jobType);
  763. sheet.SetValue(row, col++, this.jobBranch);
  764. sheet.SetValue(row, col++, this.jobStage);
  765. sheet.SetValue(row, col++, string.Format("{0:F}",this.fixedSingTime));
  766. sheet.SetValue(row, col++, string.Format("{0:F}", this.changeSingTime));
  767. sheet.SetValue(row, col++, string.Format("{0:F}", this.preCastingTime));
  768. sheet.SetValue(row, col++, string.Format("{0:F}", this.castingTime));
  769. sheet.SetValue(row, col++, string.Format("{0:F}", this.afterCastingTime));
  770. sheet.SetValue(row, col++, this.cd);
  771. string buffStr = "";
  772. if(buffList!=null)
  773. {
  774. for(int idx =0; idx < buffList.Count;idx++)
  775. {
  776. if (idx == 0)
  777. buffStr = buffList[idx].id.ToString();
  778. else
  779. buffStr = buffStr+";"+ buffList[idx].id.ToString();
  780. }
  781. }
  782. sheet.SetValue(row, col++, buffStr);
  783. for(int idx =0; idx <= 5;idx++)
  784. {
  785. sheet.SetValue(row, col++, PerceptionRange[idx]);
  786. }
  787. sheet.SetValue(row, col++, this.hide ? 1: 0);
  788. sheet.SetValue(row, col++, this.levelUpDesc);
  789. }
  790. }