BattleStatistics.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. using System;
  2. using System.Collections.Generic;
  3. public struct SkillStatistics
  4. {
  5. public string skillIcon;
  6. public int skillType;
  7. public int skillId;
  8. public int skillLevel;
  9. public int cnt;
  10. public int breakCnt;
  11. public int damage;
  12. public int heal;
  13. public int absorb;
  14. public int critCnt;
  15. public int beBlockCnt;
  16. public int beDodgeCnt;
  17. public int bePerfectDodgeCnt;
  18. public int createdCnt;
  19. public List<float> castingTimeList;
  20. public void Casting(float castingTime)
  21. {
  22. if (castingTimeList == null)
  23. castingTimeList = new List<float>();
  24. castingTimeList.Add(castingTime);
  25. cnt++;
  26. }
  27. public void AddCreateCnt()
  28. {
  29. createdCnt++;
  30. }
  31. public void ResetCreateCnt()
  32. {
  33. createdCnt = 0;
  34. }
  35. }
  36. public class FighterStatistics
  37. {
  38. public ulong fighterInstId;
  39. public long fighterId;
  40. public long usedPetId;
  41. public string actorName;
  42. public string jobIcon;
  43. public string headIcon;
  44. public int level;
  45. public int damage = 0; //输出
  46. public int heal = 0; //治疗
  47. public int hurt = 0; //受伤
  48. public int addSp = 0;
  49. public int reflectdamage = 0; //反弹伤害
  50. public int basedamage = 0; //基础输出
  51. public int naturedamage = 0;//元素输出
  52. public int petdamage = 0; //宠物输出
  53. public float basedamagePercent = 0; //基础输出比例
  54. public float naturedamagePercent = 0;//元素输出比例
  55. public float petdamagePercent = 0; //宠物输出比例
  56. public float damagePercent = 0;
  57. public float healPercent = 0;
  58. public float hurtPercent = 0;
  59. public float heroDamagePercent = 0;
  60. public float heroHealPercent = 0;
  61. public float heroHurtPercent = 0;
  62. public int critCnt = 0;
  63. public int blockCnt = 0;
  64. public int dodgeCnt = 0;
  65. public int beCritCnt = 0;
  66. public int beBlockCnt = 0;
  67. public int beDodgeCnt = 0;
  68. public int buffCnt = 0;
  69. public SkillStatistics[] skillStatistics;
  70. private int mBeginFrame = 0;
  71. private bool mDirty = false;
  72. public bool Dirty
  73. {
  74. get { return mDirty; }
  75. set { mDirty = value; }
  76. }
  77. public FighterStatistics(Fighter fighter, int frameCnt)
  78. {
  79. actorName = fighter.Name;
  80. jobIcon = fighter.Actor.ProfessionIcon;
  81. headIcon = fighter.Actor.HeadIcon;
  82. level = fighter.Actor.Level;
  83. mBeginFrame = frameCnt;
  84. fighterInstId = fighter.InstanceId;
  85. fighterId = fighter.Id;
  86. usedPetId = fighter.UsedPetId;
  87. skillStatistics = new SkillStatistics[5];
  88. for (int i = 0; i < skillStatistics.Length; i++)
  89. {
  90. skillStatistics[i].skillType = i;
  91. }
  92. }
  93. public void StatHitInfo(SkillHitFighterInfo hitInfo)
  94. {
  95. if (hitInfo.Caster != null && hitInfo.Caster.InstanceId == fighterInstId)
  96. {
  97. if(hitInfo.Skill != null && hitInfo.Skill.SkillTypeID>=0 && hitInfo.Skill.SkillTypeID < skillStatistics.Length)
  98. {
  99. int skillType = hitInfo.Skill.SkillTypeID;
  100. if (hitInfo.IsImmunity)
  101. skillStatistics[skillType].beBlockCnt++;
  102. else if (hitInfo.IsDodge)
  103. skillStatistics[skillType].beDodgeCnt++;
  104. else if (hitInfo.IsPerfectDodge)
  105. skillStatistics[skillType].bePerfectDodgeCnt++;
  106. else
  107. {
  108. if (hitInfo.IsCrit)
  109. {
  110. critCnt++;
  111. skillStatistics[skillType].critCnt++;
  112. }
  113. if (hitInfo.Damage > 0)
  114. {
  115. int hitDamage = UnityEngine.Mathf.RoundToInt(hitInfo.Damage);
  116. damage += hitDamage;
  117. basedamage += UnityEngine.Mathf.RoundToInt(hitInfo.BaseDamge);
  118. naturedamage += UnityEngine.Mathf.RoundToInt(hitInfo.NatureDamge);
  119. skillStatistics[skillType].damage += hitDamage;
  120. }
  121. }
  122. }
  123. else
  124. {
  125. if (hitInfo.Damage > 0)
  126. {
  127. int hitDamage = UnityEngine.Mathf.RoundToInt(hitInfo.Damage);
  128. damage += hitDamage;
  129. basedamage += UnityEngine.Mathf.RoundToInt(hitInfo.BaseDamge);
  130. naturedamage += UnityEngine.Mathf.RoundToInt(hitInfo.NatureDamge);
  131. }
  132. }
  133. mDirty = true;
  134. }
  135. }
  136. public void StatOtherDamage(Fighter f, int dmg)
  137. {
  138. if (f != null && f.InstanceId == fighterInstId && dmg > 0)
  139. {
  140. damage += dmg;
  141. mDirty = true;
  142. }
  143. }
  144. public void StatReflectInfo(Fighter f,int reflectDamage)
  145. {
  146. if(f != null && f.InstanceId == fighterInstId && reflectDamage > 0)
  147. {
  148. damage += reflectDamage;
  149. reflectdamage += reflectDamage;
  150. mDirty = true;
  151. }
  152. }
  153. public void StatBeHitInfo(SkillHitFighterInfo hitInfo)
  154. {
  155. if (hitInfo.Target != null && hitInfo.Target.InstanceId == fighterInstId)
  156. {
  157. if (hitInfo.IsImmunity)
  158. blockCnt++;
  159. else if (hitInfo.IsDodge)
  160. dodgeCnt++;
  161. else if (hitInfo.IsCrit)
  162. beCritCnt++;
  163. if(hitInfo.Attack > 0)
  164. {
  165. hurt += (int)hitInfo.Attack;
  166. }
  167. mDirty = true;
  168. }
  169. }
  170. public void StatReflectHurtInfo(Fighter f,int reflectHurt)
  171. {
  172. if (reflectHurt == 0) return;
  173. if(f != null && f.InstanceId == fighterInstId)
  174. {
  175. hurt += reflectHurt;
  176. }
  177. mDirty = true;
  178. }
  179. public void StatHealInfo(Fighter f,int healHp)
  180. {
  181. if(f != null && f.InstanceId == fighterInstId)
  182. {
  183. heal += healHp;
  184. mDirty = true;
  185. }
  186. }
  187. public void StatBuffInfo(Fighter f, bool negative)
  188. {
  189. if(f!=null && f.InstanceId == fighterInstId)
  190. {
  191. buffCnt++;
  192. mDirty = true;
  193. }
  194. }
  195. public void StatSPInfo(Fighter f, int sp)
  196. {
  197. if(f.InstanceId == fighterInstId)
  198. {
  199. addSp += sp;
  200. mDirty = true;
  201. }
  202. }
  203. public void OnEnterSkill (Fighter fighter, int skillType,string skillIcon,int skillId,int skillLevel)
  204. {
  205. skillStatistics[skillType].skillIcon = skillIcon;
  206. skillStatistics[skillType].skillId = skillId;
  207. skillStatistics[skillType].skillLevel = skillLevel;
  208. skillStatistics[skillType].Casting((BattleMgr.Instance.Battle.CurBattleField.BattleFrame - mBeginFrame)/Constants.frame_to_time);
  209. mDirty = true;
  210. }
  211. public void OnBreakSkill (Fighter fighter, int skillType)
  212. {
  213. //skillStatistics [skillType].breakCnt++;
  214. }
  215. }
  216. public class BattleStatistics
  217. {
  218. private List<FighterStatistics> mEnemyPetStatistics;
  219. private List<FighterStatistics> mFriendPetStatistics;
  220. private List<FighterStatistics> mEnemyStatistics;
  221. private List<FighterStatistics> mFriendStatistics;
  222. private float mBeginTime;
  223. private float mEndTime = 0;
  224. private int mBeginFrame = 0;
  225. private int mEndFrame = 0;
  226. private float factorA = 0;
  227. private float factorB = 0;
  228. private float factorC = 0;
  229. private bool bStarted = false;
  230. public float BeginTime
  231. {
  232. get { return mBeginTime; }
  233. }
  234. public float EndTime
  235. {
  236. get { return mEndFrame / Constants.frame_to_time; }
  237. }
  238. public List<FighterStatistics> FriendStatistics
  239. {
  240. get { return mFriendStatistics; }
  241. }
  242. public List<FighterStatistics> EnemyStatistics
  243. {
  244. get { return mEnemyStatistics; }
  245. }
  246. public bool Exist
  247. {
  248. get { return mFriendStatistics!=null && mFriendStatistics.Count > 0; }
  249. }
  250. public float PassedTime
  251. {
  252. get
  253. {
  254. if (null == BattleMgr.Instance.Battle)
  255. return 0;
  256. if (null == BattleMgr.Instance.Battle.CurBattleField)
  257. return 0;
  258. return (BattleMgr.Instance.Battle.CurBattleField.BattleFrame - mBeginFrame)/Constants.frame_to_time;
  259. }
  260. }
  261. public BattleStatistics()
  262. {
  263. factorB = GlobalConfig.Instance.GetConfigFloatValue(190);
  264. factorA = GlobalConfig.Instance.GetConfigFloatValue(191);
  265. factorC = GlobalConfig.Instance.GetConfigFloatValue(192);
  266. }
  267. public void Start()
  268. {
  269. bStarted = true;
  270. Clear();
  271. mBeginFrame = BattleMgr.Instance.Battle.CurBattleField.BattleFrame;
  272. }
  273. public void End()
  274. {
  275. if(bStarted)
  276. {
  277. var battle = BattleMgr.Instance.Battle;
  278. mEndFrame = battle.CurBattleField.BattleFrame - mBeginFrame;
  279. bStarted = false;
  280. }
  281. }
  282. public void Clear()
  283. {
  284. mEndFrame = 0;
  285. if (mEnemyStatistics != null)
  286. {
  287. mEnemyStatistics.Clear();
  288. }
  289. if(mFriendStatistics!=null)
  290. {
  291. mFriendStatistics.Clear();
  292. }
  293. if(mEnemyPetStatistics != null)
  294. {
  295. mEnemyPetStatistics.Clear();
  296. }
  297. if(mFriendPetStatistics != null)
  298. {
  299. mFriendPetStatistics.Clear();
  300. }
  301. }
  302. public FighterStatistics GetFighterStatistics (Fighter fighter)
  303. {
  304. if (bStarted == false) return null;
  305. if (fighter == null) return null;
  306. if(fighter.TeamSide == eTeamType.Friend)
  307. {
  308. if(fighter.IsPet)
  309. {
  310. if(mFriendPetStatistics == null)
  311. mFriendPetStatistics = new List<FighterStatistics>();
  312. for (int idx = 0; idx < mFriendPetStatistics.Count; idx++)
  313. {
  314. if (mFriendPetStatistics[idx].fighterInstId == fighter.InstanceId)
  315. {
  316. return mFriendPetStatistics[idx];
  317. }
  318. }
  319. FighterStatistics statistics = new FighterStatistics(fighter, mBeginFrame);
  320. mFriendPetStatistics.Add(statistics);
  321. return statistics;
  322. }
  323. else
  324. {
  325. if (mFriendStatistics == null)
  326. mFriendStatistics = new List<FighterStatistics>();
  327. for (int idx = 0; idx < mFriendStatistics.Count; idx++)
  328. {
  329. if (mFriendStatistics[idx].fighterInstId == fighter.InstanceId)
  330. {
  331. return mFriendStatistics[idx];
  332. }
  333. }
  334. FighterStatistics statistics = new FighterStatistics(fighter, mBeginFrame);
  335. mFriendStatistics.Add(statistics);
  336. return statistics;
  337. }
  338. }else if(fighter.TeamSide == eTeamType.Enemy)
  339. {
  340. if(fighter.IsPet)
  341. {
  342. if (mEnemyPetStatistics == null)
  343. mEnemyPetStatistics = new List<FighterStatistics>();
  344. for (int idx = 0; idx < mEnemyPetStatistics.Count; idx++)
  345. {
  346. if (mEnemyPetStatistics[idx].fighterInstId == fighter.InstanceId)
  347. {
  348. return mEnemyPetStatistics[idx];
  349. }
  350. }
  351. FighterStatistics statistics = new FighterStatistics(fighter, mBeginFrame);
  352. mEnemyPetStatistics.Add(statistics);
  353. return statistics;
  354. }
  355. else
  356. {
  357. if (mEnemyStatistics == null)
  358. mEnemyStatistics = new List<FighterStatistics>();
  359. for (int idx = 0; idx < mEnemyStatistics.Count; idx++)
  360. {
  361. if (mEnemyStatistics[idx].fighterInstId == fighter.InstanceId)
  362. {
  363. return mEnemyStatistics[idx];
  364. }
  365. }
  366. FighterStatistics statistics = new FighterStatistics(fighter, mBeginFrame);
  367. mEnemyStatistics.Add(statistics);
  368. return statistics;
  369. }
  370. }
  371. return null;
  372. }
  373. public void AnalyzeData()
  374. {
  375. if (bStarted == false) return;
  376. bool notify = false;
  377. if(mEnemyStatistics != null)
  378. {
  379. float totalDamage = 0;
  380. float totalHeal = 0;
  381. float totalHurt = 0;
  382. float totalBuffCnt = 0;
  383. float totalSp = 0;
  384. for(int idx =0; idx < mEnemyStatistics.Count;idx++)
  385. {
  386. var enemy = mEnemyStatistics[idx];
  387. if (null == enemy)
  388. continue;
  389. totalDamage += enemy.reflectdamage + enemy.basedamage + enemy.naturedamage;
  390. totalHeal += enemy.heal;
  391. totalHurt += enemy.hurt;
  392. totalBuffCnt += enemy.buffCnt;
  393. totalSp += enemy.addSp;
  394. }
  395. if(mEnemyPetStatistics != null)
  396. {
  397. for (int idx = 0; idx < mEnemyPetStatistics.Count; idx++)
  398. {
  399. var pet = mEnemyPetStatistics[idx];
  400. if (null == pet)
  401. continue;
  402. totalDamage += pet.reflectdamage + pet.basedamage + pet.naturedamage;
  403. totalHeal += pet.heal;
  404. totalHurt += pet.hurt;
  405. totalBuffCnt += pet.buffCnt;
  406. totalSp += pet.addSp;
  407. }
  408. }
  409. float avgPercent = 1.0f / mEnemyStatistics.Count;
  410. for (int idx = 0; idx < mEnemyStatistics.Count;idx++)
  411. {
  412. var enemy = mEnemyStatistics[idx];
  413. if (null == enemy)
  414. continue;
  415. if(enemy.usedPetId> 0)
  416. {
  417. var petStat = GetPetStatistics(enemy.usedPetId, eTeamType.Enemy);
  418. int pethurt = 0;
  419. int petreflectdamage = 0;
  420. int petbasedamage = 0;
  421. int petnaturedamage = 0;
  422. int petheal = 0;
  423. int petbuffCnt = 0;
  424. int petaddSp = 0;
  425. if (null != petStat)
  426. {
  427. pethurt = petStat.hurt;
  428. petreflectdamage = petStat.reflectdamage;
  429. petbasedamage = petStat.basedamage;
  430. petnaturedamage = petStat.naturedamage;
  431. petheal = petStat.heal;
  432. petbuffCnt = petStat.buffCnt;
  433. petaddSp = petStat.addSp;
  434. }
  435. enemy.petdamage = petreflectdamage + petbasedamage + petnaturedamage;
  436. enemy.damage = enemy.reflectdamage + enemy.basedamage + enemy.naturedamage;
  437. enemy.damagePercent = totalDamage > 0 ? (enemy.damage + enemy.petdamage) / totalDamage : 0;
  438. enemy.hurtPercent = totalHurt > 0 ? (enemy.hurt + pethurt) / totalHurt : 0;
  439. enemy.heroDamagePercent = totalDamage > 0 ? enemy.damage / totalDamage : 0;
  440. enemy.heroHurtPercent = totalHurt > 0 ? enemy.hurt / totalHurt : 0;
  441. float percent1 = totalHeal > 0 ? (enemy.heal + petheal) / totalHeal : avgPercent;
  442. float percent2 = totalBuffCnt > 0 ? (enemy.buffCnt + petbuffCnt) / totalBuffCnt : avgPercent;
  443. float percent3 = totalSp > 0 ? (enemy.addSp + petaddSp) / totalSp : avgPercent;
  444. enemy.healPercent = factorA * percent1 + factorB * percent2 + factorC * percent3;
  445. float percent4 = totalHeal > 0 ? enemy.heal / totalHeal : avgPercent;
  446. float percent5 = totalBuffCnt > 0 ? enemy.buffCnt / totalBuffCnt : avgPercent;
  447. float percent6 = totalSp > 0 ? enemy.addSp / totalSp : avgPercent;
  448. enemy.heroHealPercent = factorA * percent4 + factorB * percent5 + factorC * percent6;
  449. }
  450. else
  451. {
  452. enemy.petdamage = 0;
  453. enemy.damage = enemy.reflectdamage + enemy.basedamage + enemy.naturedamage;
  454. enemy.damagePercent = totalDamage > 0 ? enemy.damage / totalDamage : 0;
  455. enemy.hurtPercent = totalHurt > 0 ? enemy.hurt / totalHurt : 0;
  456. enemy.heroDamagePercent = enemy.damagePercent;
  457. enemy.heroHurtPercent = enemy.hurtPercent;
  458. float percent1 = totalHeal > 0 ? enemy.heal / totalHeal : avgPercent;
  459. float percent2 = totalBuffCnt > 0 ? enemy.buffCnt / totalBuffCnt : avgPercent;
  460. float percent3 = totalSp > 0 ? enemy.addSp / totalSp : avgPercent;
  461. enemy.healPercent = factorA * percent1 + factorB * percent2 + factorC * percent3;
  462. enemy.heroHealPercent = enemy.healPercent;
  463. }
  464. if (enemy.Dirty)
  465. {
  466. notify = true;
  467. enemy.Dirty = false;
  468. }
  469. }
  470. }
  471. if(mFriendStatistics != null)
  472. {
  473. float totalDamage = 0;
  474. float totalHeal = 0;
  475. float totalHurt = 0;
  476. float totalBuffCnt = 0;
  477. float totalSp = 0;
  478. for (int idx = 0; idx < mFriendStatistics.Count; idx++)
  479. {
  480. var friend = mFriendStatistics[idx];
  481. if (null == friend)
  482. continue;
  483. totalDamage += friend.reflectdamage + friend.basedamage + friend.naturedamage;
  484. totalHeal += friend.heal;
  485. totalHurt += friend.hurt;
  486. totalBuffCnt += friend.buffCnt;
  487. totalSp += friend.addSp;
  488. }
  489. if (mFriendPetStatistics != null)
  490. {
  491. for (int idx = 0; idx < mFriendPetStatistics.Count; idx++)
  492. {
  493. var pet = mFriendPetStatistics[idx];
  494. if (null == pet)
  495. continue;
  496. totalDamage += pet.reflectdamage + pet.basedamage + pet.naturedamage;
  497. totalHeal += pet.heal;
  498. totalHurt += pet.hurt;
  499. totalBuffCnt += pet.buffCnt;
  500. totalSp += pet.addSp;
  501. }
  502. }
  503. float avgPercent = 1.0f / mFriendStatistics.Count;
  504. for (int idx = 0; idx < mFriendStatistics.Count; idx++)
  505. {
  506. var friend = mFriendStatistics[idx];
  507. if (null == friend)
  508. continue;
  509. if (friend.usedPetId > 0)
  510. {
  511. var petStat = GetPetStatistics(friend.usedPetId, eTeamType.Friend);
  512. int pethurt = 0;
  513. int petreflectdamage = 0;
  514. int petbasedamage = 0;
  515. int petnaturedamage = 0;
  516. int petheal = 0;
  517. int petbuffCnt = 0;
  518. int petaddSp = 0;
  519. if (null != petStat)
  520. {
  521. pethurt = petStat.hurt;
  522. petreflectdamage = petStat.reflectdamage;
  523. petbasedamage = petStat.basedamage;
  524. petnaturedamage = petStat.naturedamage;
  525. petheal = petStat.heal;
  526. petbuffCnt = petStat.buffCnt;
  527. petaddSp = petStat.addSp;
  528. }
  529. friend.petdamage = petreflectdamage + petbasedamage + petnaturedamage;
  530. friend.damage = friend.reflectdamage + friend.basedamage + friend.naturedamage;
  531. friend.damagePercent = totalDamage > 0 ? (friend.damage + friend.petdamage) / totalDamage : 0;
  532. friend.hurtPercent = totalHurt > 0 ? (friend.hurt + pethurt) / totalHurt : 0;
  533. friend.heroDamagePercent = totalDamage > 0 ? friend.damage / totalDamage : 0;
  534. friend.heroHurtPercent = totalHurt > 0 ? friend.hurt / totalHurt : 0;
  535. float percent1 = totalHeal > 0 ? (friend.heal + petheal) / totalHeal : avgPercent;
  536. float percent2 = totalBuffCnt > 0 ? (friend.buffCnt + petbuffCnt) / totalBuffCnt : avgPercent;
  537. float percent3 = totalSp > 0 ? (friend.addSp + petaddSp) / totalSp : avgPercent;
  538. friend.healPercent = factorA * percent1 + factorB * percent2 + factorC * percent3;
  539. float percent4 = totalHeal > 0 ? friend.heal / totalHeal : avgPercent;
  540. float percent5 = totalBuffCnt > 0 ? friend.buffCnt / totalBuffCnt : avgPercent;
  541. float percent6 = totalSp > 0 ? friend.addSp / totalSp : avgPercent;
  542. friend.heroHealPercent = factorA * percent4 + factorB * percent5 + factorC * percent6;
  543. }
  544. else
  545. {
  546. friend.petdamage = 0;
  547. friend.damage = friend.reflectdamage + friend.basedamage + friend.naturedamage;
  548. friend.damagePercent = totalDamage > 0 ? friend.damage / totalDamage : 0;
  549. friend.hurtPercent = totalHurt > 0 ? friend.hurt / totalHurt : 0;
  550. friend.heroDamagePercent = friend.damagePercent;
  551. friend.heroHurtPercent = friend.hurtPercent;
  552. float percent1 = totalHeal > 0 ? friend.heal / totalHeal : avgPercent;
  553. float percent2 = totalBuffCnt > 0 ? friend.buffCnt / totalBuffCnt : avgPercent;
  554. float percent3 = totalSp > 0 ? friend.addSp / totalSp : avgPercent;
  555. friend.healPercent = factorA * percent1 + factorB * percent2 + factorC * percent3;
  556. friend.heroHealPercent = friend.healPercent;
  557. }
  558. if (friend.Dirty)
  559. {
  560. notify = true;
  561. friend.Dirty = false;
  562. }
  563. }
  564. }
  565. //自身输出比例设置
  566. int nMaxDamge = 0;
  567. if (null != mEnemyStatistics)
  568. {
  569. for (int idx = 0; idx < mEnemyStatistics.Count; idx++)
  570. {
  571. var enemy = mEnemyStatistics[idx];
  572. if (null == enemy)
  573. continue;
  574. nMaxDamge = Math.Max(nMaxDamge, enemy.basedamage + enemy.reflectdamage);
  575. nMaxDamge = Math.Max(nMaxDamge, enemy.naturedamage);
  576. nMaxDamge = Math.Max(nMaxDamge, enemy.petdamage);
  577. }
  578. for (int idx = 0; idx < mEnemyStatistics.Count; idx++)
  579. {
  580. var enemy = mEnemyStatistics[idx];
  581. if (null == enemy)
  582. continue;
  583. enemy.basedamagePercent = nMaxDamge > 0 ? ((float)(enemy.basedamage + enemy.reflectdamage) / nMaxDamge) : nMaxDamge;
  584. enemy.naturedamagePercent = nMaxDamge > 0 ? ((float)(enemy.naturedamage) / nMaxDamge) : nMaxDamge;
  585. enemy.petdamagePercent = nMaxDamge > 0 ? ((float)(enemy.petdamage) / nMaxDamge) : nMaxDamge;
  586. }
  587. }
  588. if (null != mFriendStatistics)
  589. {
  590. nMaxDamge = 0;
  591. for (int idx = 0; idx < mFriendStatistics.Count; idx++)
  592. {
  593. var friend = mFriendStatistics[idx];
  594. if (null == friend)
  595. continue;
  596. nMaxDamge = Math.Max(nMaxDamge, friend.basedamage + friend.reflectdamage);
  597. nMaxDamge = Math.Max(nMaxDamge, friend.naturedamage);
  598. nMaxDamge = Math.Max(nMaxDamge, friend.petdamage);
  599. }
  600. for (int idx = 0; idx < mFriendStatistics.Count; idx++)
  601. {
  602. var friend = mFriendStatistics[idx];
  603. if (null == friend)
  604. continue;
  605. friend.basedamagePercent = nMaxDamge > 0 ? ((float)(friend.basedamage+ friend.reflectdamage) / nMaxDamge) : nMaxDamge;
  606. friend.naturedamagePercent = nMaxDamge > 0 ? ((float)(friend.naturedamage) / nMaxDamge) : nMaxDamge;
  607. friend.petdamagePercent = nMaxDamge > 0 ? ((float)(friend.petdamage) / nMaxDamge) : nMaxDamge;
  608. }
  609. }
  610. if (notify)
  611. {
  612. BattleMgr.Instance.RefreshStatistics();
  613. }
  614. }
  615. private FighterStatistics GetPetStatistics(long petId, eTeamType teamType)
  616. {
  617. if(teamType == eTeamType.Friend)
  618. {
  619. if (mFriendPetStatistics == null) return null;
  620. for(int idx =0; idx < mFriendPetStatistics.Count;idx++)
  621. {
  622. if (mFriendPetStatistics[idx].fighterId == petId)
  623. return mFriendPetStatistics[idx];
  624. }
  625. }
  626. else
  627. {
  628. if (mEnemyPetStatistics == null) return null;
  629. for(int idx =0; idx < mEnemyPetStatistics.Count;idx++)
  630. {
  631. if (mEnemyPetStatistics[idx].fighterId == petId)
  632. return mEnemyPetStatistics[idx];
  633. }
  634. }
  635. return null;
  636. }
  637. }