CombatHeroController.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using System;
  2. using Common.Utility.CombatEvent;
  3. using Fort23.Core;
  4. using GameLogic.Combat.Hero;
  5. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  6. namespace GameLogic.Combat.CombatTool
  7. {
  8. public class CombatHeroController : IDisposable
  9. {
  10. private BetterList<CombatHeroEntity> myHero = new BetterList<CombatHeroEntity>();
  11. private BetterList<CombatHeroEntity> enemyHero = new BetterList<CombatHeroEntity>();
  12. private BetterList<ILifetCycleHitPoint> myHeroHitPoint = new BetterList<ILifetCycleHitPoint>();
  13. private BetterList<ILifetCycleHitPoint> enemyHeroHitPoint = new BetterList<ILifetCycleHitPoint>();
  14. protected CombatController combatController;
  15. private BetterList<CombatHeroEntity> heroDie = new BetterList<CombatHeroEntity>();
  16. private BetterList<CombatHeroEntity> heroDispose = new BetterList<CombatHeroEntity>();
  17. public void Init(CombatController combatController)
  18. {
  19. this.combatController = combatController;
  20. }
  21. public void RemoveDieHero(CombatHeroEntity combatHeroEntity)
  22. {
  23. heroDie.Remove(combatHeroEntity);
  24. if (!heroDispose.Contains(combatHeroEntity))
  25. {
  26. heroDispose.Add(combatHeroEntity);
  27. }
  28. }
  29. public void Update(float t)
  30. {
  31. for (int i = 0; i < myHero.Count; i++)
  32. {
  33. myHero[i].Update(t);
  34. }
  35. for (int i = 0; i < enemyHero.Count; i++)
  36. {
  37. enemyHero[i].Update(t);
  38. }
  39. for (int i = 0; i < heroDie.Count; i++)
  40. {
  41. heroDie[i].Update(t);
  42. }
  43. for (int i = 0; i < heroDispose.Count; i++)
  44. {
  45. heroDispose[i].Dispose();
  46. }
  47. heroDispose.Clear();
  48. }
  49. public void AddHeroDie(CombatHeroEntity hero)
  50. {
  51. heroDie.Add(hero);
  52. }
  53. public void AddHero(CombatHeroEntity hero)
  54. {
  55. if (hero.IsEnemy)
  56. {
  57. enemyHero.Add(hero);
  58. }
  59. else
  60. {
  61. myHero.Add(hero);
  62. }
  63. }
  64. public void RemoveHero(CombatHeroEntity hero)
  65. {
  66. if (hero.IsEnemy)
  67. {
  68. enemyHero.Remove(hero);
  69. }
  70. else
  71. {
  72. myHero.Remove(hero);
  73. }
  74. }
  75. public void AddHeroHitPoint(bool isEnemy, ILifetCycleHitPoint hitPoint)
  76. {
  77. if (isEnemy)
  78. {
  79. enemyHeroHitPoint.Add(hitPoint);
  80. }
  81. else
  82. {
  83. myHeroHitPoint.Add(hitPoint);
  84. }
  85. }
  86. public void RemoveHeroHitPoint(bool isEnemy, ILifetCycleHitPoint hitPoint)
  87. {
  88. if (isEnemy)
  89. {
  90. enemyHeroHitPoint.Remove(hitPoint);
  91. }
  92. else
  93. {
  94. myHeroHitPoint.Remove(hitPoint);
  95. }
  96. }
  97. public void Dispose()
  98. {
  99. myHero.Dispose();
  100. enemyHero.Dispose();
  101. }
  102. public CombatHeroEntity[] GetHero(bool isEnemy)
  103. {
  104. if (isEnemy)
  105. {
  106. return enemyHero.ToArray();
  107. }
  108. else
  109. {
  110. return myHero.ToArray();
  111. }
  112. }
  113. public ILifetCycleHitPoint[] GetHeroHitPoint(bool isEnemy)
  114. {
  115. if (isEnemy)
  116. {
  117. return enemyHeroHitPoint.ToArray();
  118. }
  119. else
  120. {
  121. return myHeroHitPoint.ToArray();
  122. }
  123. }
  124. }
  125. }