CombatHeroGameObject.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 GameTimeLine.CustomizeTimeLogic;
  9. using UnityEngine;
  10. using Utility;
  11. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  12. public class CombatHeroGameObject : IDisposable
  13. {
  14. public GameObjectPool GameObjectPool;
  15. public Transform transform
  16. {
  17. get { return GameObjectPool.own.transform; }
  18. }
  19. public Vector3 position
  20. {
  21. get { return GameObjectPool.own.transform.position; }
  22. }
  23. public Quaternion rotation
  24. {
  25. get { return GameObjectPool.own.transform.rotation; }
  26. set { GameObjectPool.own.transform.rotation = value; }
  27. }
  28. private CombatHeroEntity _combatHeroEntity;
  29. private CombatHeroHitPoint _combatHeroHitPoints = new CombatHeroHitPoint();
  30. public Transform hpTransform;
  31. public void Init(CombatHeroEntity combatHeroEntity, GameObjectPool gameObjectPool)
  32. {
  33. _combatHeroEntity = combatHeroEntity;
  34. GameObjectPool = gameObjectPool;
  35. SetGameObject(gameObjectPool);
  36. }
  37. public void SetGameObject(GameObjectPool gameObjectPool)
  38. {
  39. hpTransform = GameObjectPool.own.transform.Find("hp");
  40. if (hpTransform == null)
  41. {
  42. hpTransform = GameObjectPool.own.transform;
  43. }
  44. GameObjectPool = gameObjectPool;
  45. HitPointMono hitPointMonos = GameObjectPool.own.GetComponentInChildren<HitPointMono>(true);
  46. HitPointMono hitPointMono = hitPointMonos;
  47. _combatHeroHitPoints = new CombatHeroHitPoint();
  48. _combatHeroHitPoints.Init(_combatHeroEntity, hitPointMono);
  49. CombatController.currActiveCombat.CombatHeroController.AddHeroHitPoint(_combatHeroEntity.IsEnemy,
  50. _combatHeroHitPoints);
  51. }
  52. public void HeroDie()
  53. {
  54. CombatController.currActiveCombat.CombatHeroController.RemoveHeroHitPoint(_combatHeroEntity.IsEnemy,
  55. _combatHeroHitPoints);
  56. }
  57. public void SetPosition(Vector3 pos)
  58. {
  59. GameObjectPool.own.transform.position = pos;
  60. }
  61. public T GetILifetCycleHitPoint<T>(string hitPoinName, bool isStandType, bool isIgnoreHind)
  62. where T : ILifetCycleHitPoint
  63. {
  64. return (T)(object)_combatHeroHitPoints;
  65. }
  66. public T GetMainHotPoin<T>(bool isIgnoreHind) where T : ILifetCycleHitPoint
  67. {
  68. if (!isIgnoreHind && _combatHeroHitPoints.IsHide)
  69. {
  70. return default;
  71. }
  72. return (T)(object)_combatHeroHitPoints;
  73. }
  74. public void Dispose()
  75. {
  76. GObjectPool.Instance.Recycle(GameObjectPool);
  77. }
  78. }