CombatHeroGameObject.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 { return GameObjectPool.own.transform; }
  20. }
  21. public Vector3 position
  22. {
  23. get { return GameObjectPool.own.transform.position; }
  24. }
  25. public Quaternion rotation
  26. {
  27. get { return GameObjectPool.own.transform.rotation; }
  28. set { GameObjectPool.own.transform.rotation = value; }
  29. }
  30. private CombatHeroEntity _combatHeroEntity;
  31. private CombatHeroHitPoint _combatHeroHitPoints = new CombatHeroHitPoint();
  32. public Transform hpTransform;
  33. public void Init(CombatHeroEntity combatHeroEntity, GameObjectPool gameObjectPool)
  34. {
  35. _combatHeroEntity = combatHeroEntity;
  36. GameObjectPool = gameObjectPool;
  37. SetGameObject(gameObjectPool);
  38. }
  39. public void SetGameObject(GameObjectPool gameObjectPool)
  40. {
  41. hpTransform = GameObjectPool.own.transform.Find("hp");
  42. if (hpTransform == null)
  43. {
  44. hpTransform = GameObjectPool.own.transform;
  45. }
  46. HeroGPUMono = GameObjectPool.own.GetComponent<HeroGPUMono>();
  47. if (HeroGPUMono != null)
  48. {
  49. if (_combatHeroEntity.CurrCombatHeroInfo.heroType == 3)
  50. {
  51. HeroGPUMono.edgeStength = 3;
  52. HeroGPUMono.edgecolor = new Color(0.8f, 0.44f, 0.02f);
  53. }
  54. else if (_combatHeroEntity.CurrCombatHeroInfo.heroType == 4)
  55. {
  56. HeroGPUMono.edgeStength = 3;
  57. HeroGPUMono.edgecolor = new Color(0.8f, 0.16f, 0f);
  58. }
  59. else
  60. {
  61. HeroGPUMono.edgeStength = 0;
  62. }
  63. }
  64. GameObjectPool = gameObjectPool;
  65. HitPointMono hitPointMonos = GameObjectPool.own.GetComponentInChildren<HitPointMono>(true);
  66. HitPointMono hitPointMono = hitPointMonos;
  67. _combatHeroHitPoints = new CombatHeroHitPoint();
  68. _combatHeroHitPoints.Init(_combatHeroEntity, hitPointMono);
  69. CombatController.currActiveCombat.CombatHeroController.AddHeroHitPoint(_combatHeroEntity.IsEnemy,
  70. _combatHeroHitPoints);
  71. }
  72. public void HeroDie()
  73. {
  74. CombatController.currActiveCombat.CombatHeroController.RemoveHeroHitPoint(_combatHeroEntity.IsEnemy,
  75. _combatHeroHitPoints);
  76. }
  77. public void SetPosition(Vector3 pos)
  78. {
  79. GameObjectPool.own.transform.position = pos;
  80. }
  81. public T GetILifetCycleHitPoint<T>(string hitPoinName, bool isStandType, bool isIgnoreHind)
  82. where T : ILifetCycleHitPoint
  83. {
  84. return (T)(object)_combatHeroHitPoints;
  85. }
  86. public T GetMainHotPoin<T>(bool isIgnoreHind) where T : ILifetCycleHitPoint
  87. {
  88. if (!isIgnoreHind && _combatHeroHitPoints.IsHide)
  89. {
  90. return default;
  91. }
  92. return (T)(object)_combatHeroHitPoints;
  93. }
  94. public void Dispose()
  95. {
  96. GObjectPool.Instance.Recycle(GameObjectPool);
  97. }
  98. }