CombatHeroGameObject.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Core.Triiger;
  5. using Fort23.UTool;
  6. using GameLogic.Combat.CombatTool;
  7. using GameLogic.Combat.Hero;
  8. using GameLogic.Combat.Hero.HeroGPU;
  9. using GameTimeLine.CustomizeTimeLogic;
  10. using UnityEngine;
  11. using Utility;
  12. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  13. public class CombatHeroGameObject : IDisposable
  14. {
  15. public GameObjectPool GameObjectPool;
  16. public HeroGPUMono HeroGPUMono;
  17. public Transform transform
  18. {
  19. get
  20. {
  21. if (GameObjectPool == null)
  22. {
  23. return null;
  24. }
  25. return GameObjectPool.own.transform;
  26. }
  27. }
  28. public Vector3 position
  29. {
  30. get
  31. {
  32. if (GameObjectPool == null)
  33. {
  34. return Vector3.zero;
  35. }
  36. return GameObjectPool.own.transform.position;
  37. }
  38. }
  39. public Quaternion rotation
  40. {
  41. get
  42. {
  43. if (GameObjectPool == null)
  44. {
  45. return Quaternion.identity;
  46. }
  47. return GameObjectPool.own.transform.rotation;
  48. }
  49. set { GameObjectPool.own.transform.rotation = value; }
  50. }
  51. private ShowBaiscEntity _combatHeroEntity;
  52. private CombatHeroHitPoint _combatHeroHitPoints = new CombatHeroHitPoint();
  53. public Transform hpTransform;
  54. public void Init(ShowBaiscEntity combatHeroEntity, GameObjectPool gameObjectPool)
  55. {
  56. _combatHeroEntity = combatHeroEntity;
  57. GameObjectPool = gameObjectPool;
  58. SetGameObject(gameObjectPool);
  59. }
  60. public void SetGameObject(GameObjectPool gameObjectPool)
  61. {
  62. if (gameObjectPool == null)
  63. {
  64. _combatHeroHitPoints = new CombatHeroHitPoint();
  65. // _combatHeroHitPoints.Init(_combatHeroEntity, null);
  66. return;
  67. }
  68. hpTransform = GameObjectPool.own.transform.Find("hp");
  69. if (hpTransform == null)
  70. {
  71. hpTransform = GameObjectPool.own.transform;
  72. }
  73. HeroGPUMono = GameObjectPool.own.GetComponent<HeroGPUMono>();
  74. if (HeroGPUMono != null)
  75. {
  76. CombatHeroEntity combatHeroEntity= _combatHeroEntity as CombatHeroEntity;
  77. if (combatHeroEntity != null)
  78. {
  79. if (combatHeroEntity.CurrCombatHeroInfo.heroType == 3)
  80. {
  81. HeroGPUMono.edgeStength = 3;
  82. HeroGPUMono.edgecolor = new Color(0.8f, 0.44f, 0.02f);
  83. }
  84. else if (combatHeroEntity.CurrCombatHeroInfo.heroType == 4)
  85. {
  86. HeroGPUMono.edgeStength = 3;
  87. HeroGPUMono.edgecolor = new Color(0.8f, 0.16f, 0f);
  88. }
  89. else
  90. {
  91. HeroGPUMono.edgeStength = 0;
  92. }
  93. }
  94. }
  95. GameObjectPool = gameObjectPool;
  96. HitPointMono hitPointMonos = GameObjectPool.own.GetComponentInChildren<HitPointMono>(true);
  97. HitPointMono hitPointMono = hitPointMonos;
  98. _combatHeroHitPoints = new CombatHeroHitPoint();
  99. _combatHeroHitPoints.Init(_combatHeroEntity, hitPointMono);
  100. CombatController.currActiveCombat.CombatHeroController.AddHeroHitPoint(_combatHeroEntity.IsEnemy,
  101. _combatHeroHitPoints);
  102. }
  103. public void Update(float t)
  104. {
  105. _combatHeroHitPoints.Update(t);
  106. }
  107. public void HeroDie()
  108. {
  109. CombatController.currActiveCombat.CombatHeroController.RemoveHeroHitPoint(_combatHeroEntity.IsEnemy,
  110. _combatHeroHitPoints);
  111. }
  112. public void SetPosition(Vector3 pos)
  113. {
  114. GameObjectPool.own.transform.position = pos;
  115. }
  116. public void SetScale(Vector3 size)
  117. {
  118. GameObjectPool.own.transform.localScale = size;
  119. }
  120. public T GetILifetCycleHitPoint<T>(string hitPoinName, bool isStandType, bool isIgnoreHind)
  121. where T : ILifetCycleHitPoint
  122. {
  123. return (T)(object)_combatHeroHitPoints;
  124. }
  125. public T GetMainHotPoin<T>(bool isIgnoreHind) where T : ILifetCycleHitPoint
  126. {
  127. if (!isIgnoreHind && _combatHeroHitPoints.IsHide)
  128. {
  129. return default;
  130. }
  131. return (T)(object)_combatHeroHitPoints;
  132. }
  133. public void Dispose()
  134. {
  135. GObjectPool.Instance.Recycle(GameObjectPool);
  136. }
  137. }