CombatHeroGameObject.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 CombatHeroEntity _combatHeroEntity;
  52. private CombatHeroHitPoint _combatHeroHitPoints = new CombatHeroHitPoint();
  53. public Transform hpTransform;
  54. public void Init(CombatHeroEntity 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. if (_combatHeroEntity.CurrCombatHeroInfo.heroType == 3)
  77. {
  78. HeroGPUMono.edgeStength = 3;
  79. HeroGPUMono.edgecolor = new Color(0.8f, 0.44f, 0.02f);
  80. }
  81. else if (_combatHeroEntity.CurrCombatHeroInfo.heroType == 4)
  82. {
  83. HeroGPUMono.edgeStength = 3;
  84. HeroGPUMono.edgecolor = new Color(0.8f, 0.16f, 0f);
  85. }
  86. else
  87. {
  88. HeroGPUMono.edgeStength = 0;
  89. }
  90. }
  91. GameObjectPool = gameObjectPool;
  92. HitPointMono hitPointMonos = GameObjectPool.own.GetComponentInChildren<HitPointMono>(true);
  93. HitPointMono hitPointMono = hitPointMonos;
  94. _combatHeroHitPoints = new CombatHeroHitPoint();
  95. _combatHeroHitPoints.Init(_combatHeroEntity, hitPointMono);
  96. CombatController.currActiveCombat.CombatHeroController.AddHeroHitPoint(_combatHeroEntity.IsEnemy,
  97. _combatHeroHitPoints);
  98. }
  99. public void Update(float t)
  100. {
  101. _combatHeroHitPoints.Update(t);
  102. }
  103. public void HeroDie()
  104. {
  105. CombatController.currActiveCombat.CombatHeroController.RemoveHeroHitPoint(_combatHeroEntity.IsEnemy,
  106. _combatHeroHitPoints);
  107. }
  108. public void SetPosition(Vector3 pos)
  109. {
  110. GameObjectPool.own.transform.position = pos;
  111. }
  112. public T GetILifetCycleHitPoint<T>(string hitPoinName, bool isStandType, bool isIgnoreHind)
  113. where T : ILifetCycleHitPoint
  114. {
  115. return (T)(object)_combatHeroHitPoints;
  116. }
  117. public T GetMainHotPoin<T>(bool isIgnoreHind) where T : ILifetCycleHitPoint
  118. {
  119. if (!isIgnoreHind && _combatHeroHitPoints.IsHide)
  120. {
  121. return default;
  122. }
  123. return (T)(object)_combatHeroHitPoints;
  124. }
  125. public void Dispose()
  126. {
  127. GObjectPool.Instance.Recycle(GameObjectPool);
  128. }
  129. }