RoleAttributeData.cs 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. /// <summary>
  5. /// 角色基础属性内容相关信息
  6. /// </summary>
  7. public class RoleAttributeData
  8. {
  9. #region properties
  10. public int id;
  11. public int exp;
  12. public int gainPoint; //获取的能量点
  13. public SInt[] attrs = new SInt[ActorData.s_SecondAttrNum];
  14. #endregion
  15. private bool bValid = false;
  16. public bool valid { get { return bValid; } }
  17. public RoleAttributeData(int level)
  18. {
  19. this.id = level;
  20. Dictionary<string,string> dic = ConfigMgr.Instance.getLine(level, Config.RoleAttrCfgName);
  21. if(dic == null)
  22. {
  23. DebugHelper.LogError(string.Format("加载角色属性数据失败 id = {0}", id));
  24. bValid = false;
  25. return;
  26. }
  27. if(dic.ContainsKey("Exp"))
  28. {
  29. int.TryParse(dic["Exp"], out exp);
  30. }
  31. if(dic.ContainsKey("GetPoint"))
  32. {
  33. int.TryParse(dic["GetPoint"], out gainPoint);
  34. }
  35. int iTemp = 0;
  36. if(dic.ContainsKey("Hp") && int.TryParse(dic["Hp"], out iTemp))
  37. {
  38. attrs[ActorData.Attr_Life - ActorData.Attr_Life] = iTemp;
  39. }
  40. if(dic.ContainsKey("Sp") && int.TryParse(dic["Sp"],out iTemp))
  41. {
  42. attrs[ActorData.Attr_Sp - ActorData.Attr_Life] = iTemp;
  43. }
  44. if(dic.ContainsKey("Atk") && int.TryParse(dic["Atk"],out iTemp))
  45. {
  46. attrs[ActorData.Attr_Attack - ActorData.Attr_Life] = iTemp;
  47. }
  48. if(dic.ContainsKey("Matk") && int.TryParse(dic["Matk"],out iTemp))
  49. {
  50. attrs[ActorData.Attr_MagicAttack - ActorData.Attr_Life] = iTemp;
  51. }
  52. if(dic.ContainsKey("Def") && int.TryParse(dic["Def"],out iTemp))
  53. {
  54. attrs[ActorData.Attr_Defense - ActorData.Attr_Life] = iTemp;
  55. }
  56. if(dic.ContainsKey("Mdef") && int.TryParse(dic["Mdef"],out iTemp))
  57. {
  58. attrs[ActorData.Attr_MagicDefense - ActorData.Attr_Life] = iTemp;
  59. }
  60. if(dic.ContainsKey("Hit") && int.TryParse(dic["Hit"],out iTemp))
  61. {
  62. attrs[ActorData.Attr_Hit - ActorData.Attr_Life] = iTemp;
  63. }
  64. if(dic.ContainsKey("Dodge") && int.TryParse(dic["Dodge"],out iTemp))
  65. {
  66. attrs[ActorData.Attr_Dodge - ActorData.Attr_Life] = iTemp;
  67. }
  68. if(dic.ContainsKey("Crit") && int.TryParse(dic["Crit"], out iTemp))
  69. {
  70. attrs[ActorData.Attr_Crit - ActorData.Attr_Life] = iTemp;
  71. }
  72. if (dic.ContainsKey("Ten") && int.TryParse(dic["Ten"], out iTemp))
  73. {
  74. attrs[ActorData.Attr_Ten - ActorData.Attr_Life] = iTemp;
  75. }
  76. bValid = true;
  77. }
  78. public SInt GetAttr(int attrId)
  79. {
  80. if (attrId < ActorData.Attr_Life)
  81. return 0;
  82. return attrs[attrId - ActorData.Attr_Life];
  83. }
  84. private bool mbDisposed = false;
  85. public void Dispose()
  86. {
  87. if (mbDisposed)
  88. return;
  89. attrs = null;
  90. mbDisposed = true;
  91. }
  92. }
  93. /// <summary>
  94. /// 角色基础数据
  95. /// </summary>
  96. public class RoleBaseData
  97. {
  98. public int Id;
  99. public string Name;
  100. public string Desc;
  101. public int professionId;
  102. public int sex;
  103. public int avatarId;
  104. public string headId;
  105. public string WeaponPath;
  106. public string ClothPath;
  107. public string BattleCtrlPath;
  108. public string ShowCtrlPath;
  109. public string frameEventName;
  110. public string battleBigIcon;
  111. public bool valid
  112. {
  113. get { return isvalid; }
  114. }
  115. private bool isvalid = false;
  116. private bool mbDisposed = false;
  117. public RoleBaseData(int id)
  118. {
  119. Id = id;
  120. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.RoleCfgName);
  121. if(dic!=null)
  122. {
  123. if (dic.ContainsKey("Name"))
  124. this.Name = dic["Name"];
  125. if (dic.ContainsKey("Desc"))
  126. this.Desc = dic["Desc"];
  127. if (dic.ContainsKey("JobId"))
  128. int.TryParse(dic["JobId"], out professionId);
  129. if (dic.ContainsKey("Sex"))
  130. int.TryParse(dic["Sex"], out sex);
  131. if (dic.ContainsKey("AvatarId"))
  132. int.TryParse(dic["AvatarId"], out avatarId);
  133. if (dic.ContainsKey("HeadId"))
  134. headId = dic["HeadId"];
  135. if (dic.ContainsKey("BattleCartoonImg"))
  136. {
  137. battleBigIcon = dic["BattleCartoonImg"];
  138. }
  139. if(dic.ContainsKey("WeaponId"))
  140. {
  141. WeaponPath = dic["WeaponId"];
  142. }
  143. if (dic.ContainsKey("ClothId"))
  144. {
  145. ClothPath = dic["ClothId"];
  146. }
  147. if(dic.ContainsKey("BattleCtrl"))
  148. {
  149. BattleCtrlPath = dic["BattleCtrl"];
  150. }
  151. if(dic.ContainsKey("RoleShowCtrl"))
  152. {
  153. ShowCtrlPath = dic["RoleShowCtrl"];
  154. }
  155. isvalid = true;
  156. }
  157. else
  158. {
  159. DebugHelper.LogError(string.Format("角色{0}不存在", id));
  160. }
  161. }
  162. public void Dispose()
  163. {
  164. isvalid = false;
  165. }
  166. }
  167. /// <summary>
  168. /// NPC相关数据
  169. /// </summary>
  170. public class NpcBaseData
  171. {
  172. public int npcId;
  173. public int monsterId;
  174. public string npcName;
  175. public int level;
  176. public int avatarId;
  177. public int headId;
  178. public int professionType;
  179. public int position;
  180. public int bornEffectId;
  181. public SFloat life;
  182. public SFloat sp;
  183. public SFloat minAttack;
  184. public SFloat attack;
  185. public SFloat minMagicAttack;
  186. public SFloat magicAttack;
  187. public SFloat defense;
  188. public SFloat magicDefense;
  189. public SFloat hit;
  190. public SFloat dodge;
  191. public SFloat crit;
  192. public SFloat ten;
  193. public SFloat attackSpeed;
  194. public SFloat GodPower;
  195. public string[] normalSkillIds;
  196. public string[] skillIds;
  197. public string[] alternativeSkills;
  198. public string[] PassiveSkills;
  199. public int natureId;
  200. public int raceId;
  201. public SFloat hpRate;
  202. public SFloat spRate;
  203. public SFloat atkRate;
  204. public SFloat matkRate;
  205. public SFloat defRate;
  206. public SFloat mdefRate;
  207. public SFloat hitRate;
  208. public SFloat dodgeRate;
  209. public SFloat critRate;
  210. public SFloat tenRate;
  211. public SFloat GodPowerRate;
  212. public string headIcon;
  213. public string battleBigIcon;
  214. public string frameEventName;
  215. public bool showHpBar;
  216. public bool valid
  217. {
  218. get { return isvalid; }
  219. }
  220. private bool isvalid = false;
  221. private bool mbDisposed = false;
  222. public NpcBaseData(int id)
  223. {
  224. npcId = id;
  225. ReadFromConfig();
  226. }
  227. void ReadFromConfig()
  228. {
  229. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(this.npcId, Config.NpcCfgName);
  230. if (dic != null)
  231. {
  232. this.npcName = dic["Name"];
  233. if(dic.ContainsKey("MonsterId"))
  234. {
  235. int.TryParse(dic["MonsterId"], out monsterId);
  236. }
  237. if(dic.ContainsKey("BaseLv"))
  238. {
  239. int.TryParse(dic["BaseLv"], out level);
  240. }
  241. if(dic.ContainsKey("AvatarId"))
  242. {
  243. int.TryParse(dic["AvatarId"], out avatarId);
  244. }
  245. if(dic.ContainsKey("HeadId"))
  246. {
  247. int.TryParse(dic["HeadId"], out headId);
  248. }
  249. if(dic.ContainsKey("JobType"))
  250. {
  251. int.TryParse(dic["JobType"], out professionType);
  252. }
  253. if(dic.ContainsKey("Position"))
  254. {
  255. int.TryParse(dic["Position"], out position);
  256. }
  257. if(dic.ContainsKey("Hp"))
  258. {
  259. float temp = 0;
  260. float.TryParse(dic["Hp"], out temp);
  261. life = temp;
  262. }
  263. if(dic.ContainsKey("Sp"))
  264. {
  265. float temp = 0;
  266. float.TryParse(dic["Sp"], out temp);
  267. sp = temp;
  268. }
  269. if(dic.ContainsKey("Atk"))
  270. {
  271. float temp = 0;
  272. float.TryParse(dic["Atk"], out temp);
  273. attack = temp;
  274. }
  275. if(dic.ContainsKey("MinAtk"))
  276. {
  277. float temp = 0;
  278. float.TryParse(dic["MinAtk"], out temp);
  279. minAttack = temp;
  280. }
  281. if(dic.ContainsKey("Matk"))
  282. {
  283. float temp = 0;
  284. float.TryParse(dic["Matk"], out temp);
  285. magicAttack = temp;
  286. }
  287. if(dic.ContainsKey("MinMatk"))
  288. {
  289. float temp = 0;
  290. float.TryParse(dic["MinMatk"], out temp);
  291. minMagicAttack = temp;
  292. }
  293. if(dic.ContainsKey("Def"))
  294. {
  295. float temp = 0;
  296. float.TryParse(dic["Def"], out temp);
  297. defense = temp;
  298. }
  299. if(dic.ContainsKey("Mdef"))
  300. {
  301. float temp = 0;
  302. float.TryParse(dic["Mdef"], out temp);
  303. magicDefense = temp;
  304. }
  305. if(dic.ContainsKey("Hit"))
  306. {
  307. float temp = 0;
  308. float.TryParse(dic["Hit"], out temp);
  309. hit = temp;
  310. }
  311. if(dic.ContainsKey("Dodge"))
  312. {
  313. float temp = 0;
  314. float.TryParse(dic["Dodge"], out temp);
  315. dodge = temp;
  316. }
  317. if(dic.ContainsKey("Crit"))
  318. {
  319. float temp = 0;
  320. float.TryParse(dic["Crit"], out temp);
  321. crit = temp;
  322. }
  323. if(dic.ContainsKey("Ten"))
  324. {
  325. float temp = 0;
  326. float.TryParse(dic["Ten"], out temp);
  327. ten = temp;
  328. }
  329. if(dic.ContainsKey("AttackSpeed"))
  330. {
  331. float temp = 0;
  332. float.TryParse(dic["AttackSpeed"], out temp);
  333. attackSpeed = temp;
  334. }
  335. if(dic.ContainsKey("NatureId"))
  336. {
  337. int.TryParse(dic["NatureId"], out natureId);
  338. }
  339. if(dic.ContainsKey("RaceId"))
  340. {
  341. int.TryParse(dic["RaceId"], out raceId);
  342. }
  343. if (dic.ContainsKey("NormalSkillIds"))
  344. {
  345. normalSkillIds = StringUtil.split(dic["NormalSkillIds"], ';');
  346. }
  347. if(dic.ContainsKey("SkillIds"))
  348. {
  349. skillIds = StringUtil.split(dic["SkillIds"], ';');
  350. }
  351. if(dic.ContainsKey("AlternativeSkills"))
  352. {
  353. alternativeSkills = StringUtil.split(dic["AlternativeSkills"], ';');
  354. }
  355. if (dic.ContainsKey("PassiveSkills"))
  356. {
  357. PassiveSkills = StringUtil.split(dic["PassiveSkills"], ';');
  358. }
  359. if (dic.ContainsKey("BattleCartoonImg"))
  360. {
  361. battleBigIcon = dic["BattleCartoonImg"];
  362. }
  363. if(dic.ContainsKey("Head"))
  364. {
  365. headIcon = dic["Head"];
  366. }
  367. if(dic.ContainsKey("HPBar"))
  368. {
  369. int temp = 0;
  370. int.TryParse(dic["HPBar"], out temp);
  371. showHpBar = temp > 0;
  372. }
  373. if(dic.ContainsKey("BornEffect"))
  374. {
  375. int.TryParse(dic["BornEffect"], out bornEffectId);
  376. }
  377. if(dic.ContainsKey("ArtifactValue"))
  378. {
  379. float temp = 0;
  380. float.TryParse(dic["ArtifactValue"], out temp);
  381. GodPower = temp;
  382. }
  383. if (dic.ContainsKey("ArtifactValueRate"))
  384. {
  385. float temp = 0;
  386. float.TryParse(dic["ArtifactValueRate"], out temp);
  387. GodPowerRate = temp;
  388. }
  389. hpRate = ReadAttrRate(dic, "HpRate");
  390. spRate = ReadAttrRate(dic, "SpRate");
  391. atkRate = ReadAttrRate(dic, "AtkRate");
  392. matkRate = ReadAttrRate(dic, "MatkRate");
  393. defRate = ReadAttrRate(dic, "DefRate");
  394. mdefRate = ReadAttrRate(dic, "MdefRate");
  395. hitRate = ReadAttrRate(dic, "HitRate");
  396. dodgeRate = ReadAttrRate(dic, "DodgeRate");
  397. critRate = ReadAttrRate(dic, "CritRate");
  398. tenRate = ReadAttrRate(dic, "TenRate");
  399. isvalid = true;
  400. }
  401. else
  402. {
  403. DebugHelper.Log("NPC配置不存在!ID: " + npcId);
  404. }
  405. }
  406. SFloat ReadAttrRate(Dictionary<string, string> dic, string attrName)
  407. {
  408. if (dic == null)
  409. {
  410. return 0;
  411. }
  412. if(dic.ContainsKey(attrName))
  413. {
  414. int temp;
  415. int.TryParse(dic[attrName], out temp);
  416. return temp/10000.0f;
  417. }
  418. return 0;
  419. }
  420. public void Dispose()
  421. {
  422. if (mbDisposed)
  423. return;
  424. skillIds = null;
  425. normalSkillIds = null;
  426. PassiveSkills = null;
  427. mbDisposed = true;
  428. }
  429. }
  430. public struct stPetSkillData
  431. {
  432. private int mSkillId;
  433. private List<int> mTriggerRate;
  434. public int SkillId
  435. {
  436. get { return mSkillId; }
  437. set { mSkillId = value; }
  438. }
  439. public List<int> TriggerRate
  440. {
  441. get { return mTriggerRate; }
  442. set { mTriggerRate = value; }
  443. }
  444. }
  445. public class PetBossBaseData: PetBaseData
  446. {
  447. public PetBossBaseData(int id):base(id)
  448. {
  449. petId = id;
  450. ReadFromConfig();
  451. }
  452. protected override void ReadFromConfig()
  453. {
  454. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(petId, Config.PetBossCfgName);
  455. if (dic != null)
  456. {
  457. this.petName = dic["Name"];
  458. if (dic.ContainsKey("AvatarId"))
  459. {
  460. int.TryParse(dic["AvatarId"], out avatarId);
  461. }
  462. if (dic.ContainsKey("JobType"))
  463. {
  464. int.TryParse(dic["JobType"], out profession);
  465. }
  466. if (dic.ContainsKey("Head"))
  467. {
  468. headIcon = dic["Head"];
  469. }
  470. if (dic.ContainsKey("Quality"))
  471. {
  472. int.TryParse(dic["Quality"], out quality);
  473. }
  474. if (dic.ContainsKey("NatureType"))
  475. {
  476. int.TryParse(dic["NatureType"], out natureId);
  477. }
  478. if (dic.ContainsKey("Pos"))
  479. {
  480. int.TryParse(dic["Pos"], out position);
  481. }
  482. if (dic.ContainsKey("Hp"))
  483. {
  484. float temp = 0;
  485. float.TryParse(dic["Hp"], out temp);
  486. life = temp;
  487. }
  488. if (dic.ContainsKey("Sp"))
  489. {
  490. float temp = 0;
  491. float.TryParse(dic["Sp"], out temp);
  492. sp = temp;
  493. }
  494. if (dic.ContainsKey("Atk"))
  495. {
  496. float temp = 0;
  497. float.TryParse(dic["Atk"], out temp);
  498. attack = temp;
  499. }
  500. if (dic.ContainsKey("Matk"))
  501. {
  502. float temp = 0;
  503. float.TryParse(dic["Matk"], out temp);
  504. magicAttack = temp;
  505. }
  506. if (dic.ContainsKey("Def"))
  507. {
  508. float temp = 0;
  509. float.TryParse(dic["Def"], out temp);
  510. defense = temp;
  511. }
  512. if (dic.ContainsKey("Mdef"))
  513. {
  514. float temp = 0;
  515. float.TryParse(dic["Mdef"], out temp);
  516. magicDefense = temp;
  517. }
  518. if (dic.ContainsKey("Hit"))
  519. {
  520. float temp = 0;
  521. float.TryParse(dic["Hit"], out temp);
  522. hit = temp;
  523. }
  524. if (dic.ContainsKey("Dodge"))
  525. {
  526. float temp = 0;
  527. float.TryParse(dic["Dodge"], out temp);
  528. dodge = temp;
  529. }
  530. if (dic.ContainsKey("Crit"))
  531. {
  532. float temp = 0;
  533. float.TryParse(dic["Crit"], out temp);
  534. crit = temp;
  535. }
  536. if (dic.ContainsKey("Ten"))
  537. {
  538. float temp = 0;
  539. float.TryParse(dic["Ten"], out temp);
  540. ten = temp;
  541. }
  542. if (dic.ContainsKey("AttackSpeed"))
  543. {
  544. float temp = 0;
  545. float.TryParse(dic["AttackSpeed"], out temp);
  546. attackSpeed = temp;
  547. }
  548. if (dic.ContainsKey("NormalSkillIds"))
  549. {
  550. normalSkillIds = StringUtil.split(dic["NormalSkillIds"], ';');
  551. }
  552. skills = new stPetSkillData[3];
  553. for (int idx = 1; idx <= 3; idx++)
  554. {
  555. string skillKey = "Skill" + idx;
  556. string skillRateKey = skillKey + "Rate";
  557. if (dic.ContainsKey(skillKey))
  558. {
  559. int skillId = 0;
  560. stPetSkillData skillData = new stPetSkillData();
  561. int.TryParse(dic[skillKey], out skillId);
  562. if (skillId > 0)
  563. {
  564. skillData.SkillId = skillId;
  565. if (dic.ContainsKey(skillRateKey))
  566. {
  567. skillData.TriggerRate = StringUtil.convert2IntList(dic[skillRateKey], ';');
  568. }
  569. skills[idx - 1] = skillData;
  570. if (idx == 1)
  571. {
  572. SkillParam p = new SkillParam(skillId, 1);
  573. testSkills.Add(p);
  574. }
  575. else
  576. {
  577. SkillParam p = new SkillParam(skillId, 1, skillData.TriggerRate[0]);
  578. testSkills.Add(p);
  579. }
  580. }
  581. }
  582. }
  583. if (dic.ContainsKey("EmptySkill"))
  584. {
  585. int.TryParse(dic["EmptySkill"], out emptySkillId);
  586. }
  587. if (dic.ContainsKey("BattleCtrl"))
  588. {
  589. battleCtrl = dic["BattleCtrl"];
  590. }
  591. if (dic.ContainsKey("ShowCtrl"))
  592. {
  593. showCtrl = dic["ShowCtrl"];
  594. }
  595. hpRate = ReadAttrRate(dic, "HpRate");
  596. spRate = ReadAttrRate(dic, "SpRate");
  597. atkRate = ReadAttrRate(dic, "AtkRate");
  598. matkRate = ReadAttrRate(dic, "MatkRate");
  599. defRate = ReadAttrRate(dic, "DefRate");
  600. mdefRate = ReadAttrRate(dic, "MdefRate");
  601. hitRate = ReadAttrRate(dic, "HitRate");
  602. dodgeRate = ReadAttrRate(dic, "DodgeRate");
  603. critRate = ReadAttrRate(dic, "CritRate");
  604. tenRate = ReadAttrRate(dic, "TenRate");
  605. isvalid = true;
  606. }
  607. else
  608. {
  609. DebugHelper.LogError("宠物配置不存在!ID: " + petId);
  610. }
  611. }
  612. }
  613. public class PetBaseData
  614. {
  615. public int petId;
  616. public string petName;
  617. public int avatarId;
  618. public int position;
  619. public int quality;
  620. public int natureId;
  621. public int profession;
  622. public string headIcon;
  623. public string battleCtrl;
  624. public string showCtrl;
  625. public string[] normalSkillIds;
  626. public stPetSkillData[] skills;
  627. public int emptySkillId;
  628. public SFloat life;
  629. public SFloat sp;
  630. public SFloat attack;
  631. public SFloat magicAttack;
  632. public SFloat defense;
  633. public SFloat magicDefense;
  634. public SFloat hit;
  635. public SFloat dodge;
  636. public SFloat crit;
  637. public SFloat ten;
  638. public SFloat attackSpeed;
  639. public SFloat hpRate;
  640. public SFloat spRate;
  641. public SFloat atkRate;
  642. public SFloat matkRate;
  643. public SFloat defRate;
  644. public SFloat mdefRate;
  645. public SFloat hitRate;
  646. public SFloat dodgeRate;
  647. public SFloat critRate;
  648. public SFloat tenRate;
  649. public List<SkillParam> testSkills = new List<SkillParam>();
  650. public bool valid
  651. {
  652. get { return isvalid; }
  653. }
  654. protected bool isvalid = false;
  655. private bool mbDisposed = false;
  656. public PetBaseData(int id)
  657. {
  658. petId = id;
  659. ReadFromConfig();
  660. }
  661. protected virtual void ReadFromConfig()
  662. {
  663. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(petId, Config.PetCfgName);
  664. if (dic != null)
  665. {
  666. this.petName = dic["Name"];
  667. if (dic.ContainsKey("AvatarId"))
  668. {
  669. int.TryParse(dic["AvatarId"], out avatarId);
  670. }
  671. if(dic.ContainsKey("JobType"))
  672. {
  673. int.TryParse(dic["JobType"], out profession);
  674. }
  675. if (dic.ContainsKey("Icon"))
  676. {
  677. headIcon = dic["Icon"];
  678. }
  679. if(dic.ContainsKey("Quality"))
  680. {
  681. int.TryParse(dic["Quality"], out quality);
  682. }
  683. if (dic.ContainsKey("NatureType"))
  684. {
  685. int.TryParse(dic["NatureType"], out natureId);
  686. }
  687. if (dic.ContainsKey("Pos"))
  688. {
  689. int.TryParse(dic["Pos"], out position);
  690. }
  691. if (dic.ContainsKey("Hp"))
  692. {
  693. float temp = 0;
  694. float.TryParse(dic["Hp"], out temp);
  695. life = temp;
  696. }
  697. if (dic.ContainsKey("Sp"))
  698. {
  699. float temp = 0;
  700. float.TryParse(dic["Sp"], out temp);
  701. sp = temp;
  702. }
  703. if (dic.ContainsKey("Atk"))
  704. {
  705. float temp = 0;
  706. float.TryParse(dic["Atk"], out temp);
  707. attack = temp;
  708. }
  709. if (dic.ContainsKey("Matk"))
  710. {
  711. float temp = 0;
  712. float.TryParse(dic["Matk"], out temp);
  713. magicAttack = temp;
  714. }
  715. if (dic.ContainsKey("Def"))
  716. {
  717. float temp = 0;
  718. float.TryParse(dic["Def"], out temp);
  719. defense = temp;
  720. }
  721. if (dic.ContainsKey("Mdef"))
  722. {
  723. float temp = 0;
  724. float.TryParse(dic["Mdef"], out temp);
  725. magicDefense = temp;
  726. }
  727. if (dic.ContainsKey("Hit"))
  728. {
  729. float temp = 0;
  730. float.TryParse(dic["Hit"], out temp);
  731. hit = temp;
  732. }
  733. if (dic.ContainsKey("Dodge"))
  734. {
  735. float temp = 0;
  736. float.TryParse(dic["Dodge"], out temp);
  737. dodge = temp;
  738. }
  739. if (dic.ContainsKey("Crit"))
  740. {
  741. float temp = 0;
  742. float.TryParse(dic["Crit"], out temp);
  743. crit = temp;
  744. }
  745. if (dic.ContainsKey("Ten"))
  746. {
  747. float temp = 0;
  748. float.TryParse(dic["Ten"], out temp);
  749. ten = temp;
  750. }
  751. if (dic.ContainsKey("AttackSpeed"))
  752. {
  753. float temp = 0;
  754. float.TryParse(dic["AttackSpeed"], out temp);
  755. attackSpeed = temp;
  756. }
  757. if (dic.ContainsKey("NormalSkillIds"))
  758. {
  759. normalSkillIds = StringUtil.split(dic["NormalSkillIds"], ';');
  760. }
  761. skills = new stPetSkillData[3];
  762. for (int idx =1; idx <= 3; idx++)
  763. {
  764. string skillKey = "Skill" + idx;
  765. string skillRateKey = skillKey + "Rate";
  766. if (dic.ContainsKey(skillKey))
  767. {
  768. int skillId = 0;
  769. stPetSkillData skillData = new stPetSkillData();
  770. int.TryParse(dic[skillKey], out skillId);
  771. if (skillId > 0)
  772. {
  773. skillData.SkillId = skillId;
  774. if (dic.ContainsKey(skillRateKey))
  775. {
  776. skillData.TriggerRate = StringUtil.convert2IntList(dic[skillRateKey], ';');
  777. }
  778. skills[idx-1] = skillData;
  779. if(idx == 1)
  780. {
  781. SkillParam p = new SkillParam(skillId, 1);
  782. testSkills.Add(p);
  783. }
  784. else
  785. {
  786. SkillParam p = new SkillParam(skillId, 1,skillData.TriggerRate[0]);
  787. testSkills.Add(p);
  788. }
  789. }
  790. }
  791. }
  792. if(dic.ContainsKey("EmptySkill"))
  793. {
  794. int.TryParse(dic["EmptySkill"], out emptySkillId);
  795. }
  796. if(dic.ContainsKey("BattleCtrl"))
  797. {
  798. battleCtrl = dic["BattleCtrl"];
  799. }
  800. if(dic.ContainsKey("ShowCtrl"))
  801. {
  802. showCtrl = dic["ShowCtrl"];
  803. }
  804. hpRate = ReadAttrRate(dic, "HpRate");
  805. spRate = ReadAttrRate(dic, "SpRate");
  806. atkRate = ReadAttrRate(dic, "AtkRate");
  807. matkRate = ReadAttrRate(dic, "MatkRate");
  808. defRate = ReadAttrRate(dic, "DefRate");
  809. mdefRate = ReadAttrRate(dic, "MdefRate");
  810. hitRate = ReadAttrRate(dic, "HitRate");
  811. dodgeRate = ReadAttrRate(dic, "DodgeRate");
  812. critRate = ReadAttrRate(dic, "CritRate");
  813. tenRate = ReadAttrRate(dic, "TenRate");
  814. isvalid = true;
  815. }
  816. else
  817. {
  818. DebugHelper.LogError("宠物配置不存在!ID: " + petId);
  819. }
  820. }
  821. protected SFloat ReadAttrRate(Dictionary<string, string> dic, string attrName)
  822. {
  823. if (dic == null)
  824. {
  825. return 0;
  826. }
  827. if (dic.ContainsKey(attrName))
  828. {
  829. int temp;
  830. int.TryParse(dic[attrName], out temp);
  831. return temp / 10000.0f;
  832. }
  833. return 0;
  834. }
  835. public void Dispose()
  836. {
  837. if (mbDisposed)
  838. return;
  839. normalSkillIds = null;
  840. skills = null;
  841. mbDisposed = true;
  842. }
  843. }
  844. public class PetAdvanceData
  845. {
  846. public Dictionary<int, List<ValType>> advanceData;
  847. public Dictionary<int, List<ValType>> advanceRateData;
  848. public PetAdvanceData(int id)
  849. {
  850. ReadFromConfig(id);
  851. }
  852. void ReadFromConfig(int petId)
  853. {
  854. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(petId, Config.PetProgressCfgName);
  855. if (dic != null)
  856. {
  857. advanceData = new Dictionary<int, List<ValType>>();
  858. advanceRateData = new Dictionary<int, List<ValType>>();
  859. for (int idx = 1; idx <= 5; idx++)
  860. {
  861. string attributeKey = "Attribute" + idx;
  862. string attributeRateKey = "AttributeRateAdd" + idx;
  863. if (dic.ContainsKey(attributeKey))
  864. {
  865. string temp = dic[attributeKey];
  866. if(!string.IsNullOrEmpty(temp))
  867. {
  868. List<ValType> advanceVals = new List<ValType>();
  869. string[] tempList = temp.Split(';');
  870. for(int jdx = 0; jdx < tempList.Length;jdx++)
  871. {
  872. string[] valList = tempList[jdx].Split(':');
  873. if(valList.Length == 2)
  874. {
  875. int keyVal = 0;
  876. int iVal = 0;
  877. int.TryParse(valList[0], out keyVal);
  878. int.TryParse(valList[1], out iVal);
  879. ValType valType = new ValType(keyVal, iVal);
  880. advanceVals.Add(valType);
  881. }
  882. }
  883. advanceData.Add(idx, advanceVals);
  884. }
  885. }
  886. if(dic.ContainsKey(attributeRateKey))
  887. {
  888. string temp = dic[attributeRateKey];
  889. if (!string.IsNullOrEmpty(temp))
  890. {
  891. List<ValType> advanceRateVals = new List<ValType>();
  892. string[] tempList = temp.Split(';');
  893. for (int jdx = 0; jdx < tempList.Length; jdx++)
  894. {
  895. string[] valList = tempList[jdx].Split(':');
  896. if (valList.Length == 2)
  897. {
  898. int keyVal = 0;
  899. int iVal = 0;
  900. int.TryParse(valList[0], out keyVal);
  901. int.TryParse(valList[1], out iVal);
  902. ValType valType = new ValType(keyVal, iVal);
  903. advanceRateVals.Add(valType);
  904. }
  905. }
  906. advanceRateData.Add(idx, advanceRateVals);
  907. }
  908. }
  909. }
  910. }
  911. else
  912. {
  913. DebugHelper.LogError("宠物进阶表中没有宠物配置!ID: " + petId);
  914. }
  915. }
  916. }
  917. //伙伴基础数据
  918. public class FellowBaseData
  919. {
  920. private string[] mNormalSkillIds;
  921. private string[] mSkillIds;
  922. private string[] mAlternativeSkills;
  923. private bool isValid = false;
  924. public bool valid
  925. {
  926. get { return isValid; }
  927. }
  928. public int Id;
  929. public string Name;
  930. public string Desc;
  931. public int AvatarId;
  932. public int NatureId;
  933. public int RaceId;
  934. public int Position;
  935. public int JobType;
  936. public int JobStage;
  937. public int JobBranch;
  938. public SFloat STRRate;
  939. public SFloat INTRate;
  940. public SFloat AGIRate;
  941. public SFloat DEXRate;
  942. public SFloat LUCKRate;
  943. public SFloat VITRate;
  944. public SFloat AttackSpeed;
  945. public string[] NormalSkillIds { get { return mNormalSkillIds; } }
  946. public string[] SkillIds { get { return mSkillIds; } }
  947. public string[] AlternativeSkills { get { return mAlternativeSkills; } }
  948. public SInt[] attrs = new SInt[ActorData.s_SecondAttrNum];
  949. public string frameEventName;
  950. public string ProfessionIcon;
  951. public string HeadIcon;
  952. public string ShowAnimCtrl;
  953. public string BattleAnimCtrl;
  954. public string battleBigIcon;
  955. public FellowBaseData(int id)
  956. {
  957. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.FellowCfgName);
  958. if (dic != null)
  959. {
  960. this.Id = id;
  961. this.Name = dic["Name"];
  962. this.Desc = dic["Desc"];
  963. this.ProfessionIcon = dic["JobIcon"];
  964. this.HeadIcon = dic["HeadId"];
  965. int.TryParse(dic["AvatarId"], out this.AvatarId);
  966. int.TryParse(dic["Position"], out this.Position);
  967. int.TryParse(dic["NatureId"], out this.NatureId);
  968. int.TryParse(dic["RaceId"], out this.RaceId);
  969. int.TryParse(dic["JobType"], out this.JobType);
  970. int temp = 0;
  971. int.TryParse(dic["StrRate"], out temp);
  972. STRRate = temp * 0.0001f;
  973. int.TryParse(dic["IntRate"], out temp);
  974. INTRate = temp * 0.0001f;
  975. int.TryParse(dic["AgiRate"], out temp);
  976. AGIRate = temp * 0.0001f;
  977. int.TryParse(dic["DexRate"], out temp);
  978. DEXRate = temp * 0.0001f;
  979. int.TryParse(dic["LucRate"], out temp);
  980. LUCKRate = temp * 0.0001f;
  981. int.TryParse(dic["ViteRate"], out temp);
  982. VITRate = temp * 0.0001f;
  983. int.TryParse(dic["Aspd"], out temp);
  984. AttackSpeed = temp;
  985. if(dic.ContainsKey("JobStage"))
  986. {
  987. int.TryParse(dic["JobStage"], out this.JobStage);
  988. }
  989. if(dic.ContainsKey("JobBranch"))
  990. {
  991. int.TryParse(dic["JobBranch"], out this.JobBranch);
  992. }
  993. if (dic.ContainsKey("Hp") && int.TryParse(dic["Hp"], out temp))
  994. {
  995. attrs[ActorData.Attr_Life - ActorData.Attr_Life] = temp;
  996. }
  997. if (dic.ContainsKey("Sp") && int.TryParse(dic["Sp"], out temp))
  998. {
  999. attrs[ActorData.Attr_Sp - ActorData.Attr_Life] = temp;
  1000. }
  1001. if (dic.ContainsKey("Atk") && int.TryParse(dic["Atk"], out temp))
  1002. {
  1003. attrs[ActorData.Attr_Attack - ActorData.Attr_Life] = temp;
  1004. }
  1005. if (dic.ContainsKey("Matk") && int.TryParse(dic["Matk"], out temp))
  1006. {
  1007. attrs[ActorData.Attr_MagicAttack - ActorData.Attr_Life] = temp;
  1008. }
  1009. if (dic.ContainsKey("Def") && int.TryParse(dic["Def"], out temp))
  1010. {
  1011. attrs[ActorData.Attr_Defense - ActorData.Attr_Life] = temp;
  1012. }
  1013. if (dic.ContainsKey("Mdef") && int.TryParse(dic["Mdef"], out temp))
  1014. {
  1015. attrs[ActorData.Attr_MagicDefense - ActorData.Attr_Life] = temp;
  1016. }
  1017. if (dic.ContainsKey("Hit") && int.TryParse(dic["Hit"], out temp))
  1018. {
  1019. attrs[ActorData.Attr_Hit - ActorData.Attr_Life] = temp;
  1020. }
  1021. if (dic.ContainsKey("Dodge") && int.TryParse(dic["Dodge"], out temp))
  1022. {
  1023. attrs[ActorData.Attr_Dodge - ActorData.Attr_Life] = temp;
  1024. }
  1025. if (dic.ContainsKey("Crit") && int.TryParse(dic["Crit"], out temp))
  1026. {
  1027. attrs[ActorData.Attr_Crit - ActorData.Attr_Life] = temp;
  1028. }
  1029. if (dic.ContainsKey("Ten") && int.TryParse(dic["Ten"], out temp))
  1030. {
  1031. attrs[ActorData.Attr_Ten - ActorData.Attr_Life] = temp;
  1032. }
  1033. if (dic.ContainsKey("NormalSkillIds"))
  1034. {
  1035. mNormalSkillIds = StringUtil.split(dic["NormalSkillIds"], ';');
  1036. }
  1037. if (dic.ContainsKey("SkillIds"))
  1038. {
  1039. mSkillIds = StringUtil.split(dic["SkillIds"], ';');
  1040. }
  1041. if(dic.ContainsKey("AlternativeSkills"))
  1042. {
  1043. mAlternativeSkills = StringUtil.split(dic["AlternativeSkills"], ';');
  1044. }
  1045. if(dic.ContainsKey("ShowCtrl"))
  1046. {
  1047. ShowAnimCtrl = dic["ShowCtrl"];
  1048. }
  1049. if(dic.ContainsKey("BattleCtrl"))
  1050. {
  1051. BattleAnimCtrl = dic["BattleCtrl"];
  1052. }
  1053. if (dic.ContainsKey("BattleCartoonImg"))
  1054. {
  1055. battleBigIcon = dic["BattleCartoonImg"];
  1056. }
  1057. isValid = true;
  1058. }
  1059. }
  1060. public SInt GetAttr(int attrId)
  1061. {
  1062. if (attrId < ActorData.Attr_Life)
  1063. return 0;
  1064. return attrs[attrId - ActorData.Attr_Life];
  1065. }
  1066. public void Dispose()
  1067. {
  1068. isValid = false;
  1069. mNormalSkillIds = null;
  1070. mSkillIds = null;
  1071. attrs = null;
  1072. }
  1073. }
  1074. //伙伴属性数据
  1075. public class FellowAttributeData
  1076. {
  1077. #region properties
  1078. public int id;
  1079. public int exp;
  1080. public int gainPoint; //获取的能量点
  1081. public int upgradeCost; //升级费用
  1082. #endregion
  1083. private bool bValid = false;
  1084. public bool valid { get { return bValid; } }
  1085. public FellowAttributeData(int level)
  1086. {
  1087. this.id = level;
  1088. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(level, Config.FellowAttrCfgName);
  1089. if (dic == null)
  1090. {
  1091. DebugHelper.LogError(string.Format("加载角色属性数据失败 id = {0}", id));
  1092. bValid = false;
  1093. return;
  1094. }
  1095. if (dic.ContainsKey("Exp"))
  1096. {
  1097. int.TryParse(dic["Exp"], out exp);
  1098. }
  1099. if (dic.ContainsKey("Money"))
  1100. {
  1101. int.TryParse(dic["Money"], out upgradeCost);
  1102. }
  1103. bValid = true;
  1104. }
  1105. private bool mbDisposed = false;
  1106. public void Dispose()
  1107. {
  1108. if (mbDisposed)
  1109. return;
  1110. mbDisposed = true;
  1111. }
  1112. }