CombatHeroGameObject.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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,_combatHeroHitPoints);
  50. }
  51. public void HeroDie()
  52. {
  53. CombatController.currActiveCombat.CombatHeroController.RemoveHeroHitPoint(_combatHeroEntity.IsEnemy,_combatHeroHitPoints);
  54. }
  55. public void SetPosition(Vector3 pos)
  56. {
  57. GameObjectPool.own.transform.position = pos;
  58. }
  59. public T GetILifetCycleHitPoint<T>(string hitPoinName, bool isStandType, bool isIgnoreHind)
  60. where T : ILifetCycleHitPoint
  61. {
  62. return (T)(object)_combatHeroHitPoints;
  63. }
  64. public T GetMainHotPoin<T>(bool isIgnoreHind) where T : ILifetCycleHitPoint
  65. {
  66. return (T)(object)_combatHeroHitPoints;
  67. }
  68. public void Dispose()
  69. {
  70. GObjectPool.Instance.Recycle(GameObjectPool);
  71. }
  72. }