CombatHeroGameObject.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Fort23.UTool;
  5. using GameLogic.Combat.CombatTool;
  6. using GameLogic.Combat.Hero;
  7. using GameTimeLine.CustomizeTimeLogic;
  8. using UnityEngine;
  9. using Utility;
  10. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  11. public class CombatHeroGameObject: IDisposable
  12. {
  13. public GameObjectPool GameObjectPool;
  14. public Vector3 position
  15. {
  16. get { return GameObjectPool.own.transform.position; }
  17. }
  18. public Quaternion rotation
  19. {
  20. get { return GameObjectPool.own.transform.rotation; }
  21. set { GameObjectPool.own.transform.rotation=value; }
  22. }
  23. private CombatHeroEntity _combatHeroEntity;
  24. private CombatHeroHitPoint _combatHeroHitPoints = new CombatHeroHitPoint();
  25. public Transform hpTransform;
  26. public void Init(CombatHeroEntity combatHeroEntity, GameObjectPool gameObjectPool)
  27. {
  28. _combatHeroEntity = combatHeroEntity;
  29. GameObjectPool = gameObjectPool;
  30. SetGameObject(gameObjectPool);
  31. }
  32. public void SetGameObject(GameObjectPool gameObjectPool)
  33. {
  34. hpTransform = GameObjectPool.own.transform.Find("hp");
  35. if (hpTransform == null)
  36. {
  37. hpTransform = GameObjectPool.own.transform;
  38. }
  39. GameObjectPool = gameObjectPool;
  40. HitPointMono hitPointMonos = GameObjectPool.own.GetComponentInChildren<HitPointMono>(true);
  41. HitPointMono hitPointMono = hitPointMonos;
  42. _combatHeroHitPoints = new CombatHeroHitPoint();
  43. _combatHeroHitPoints.Init(_combatHeroEntity, hitPointMono);
  44. CombatController.currActiveCombat.CombatHeroController.AddHeroHitPoint(_combatHeroEntity.IsEnemy,_combatHeroHitPoints);
  45. }
  46. public void HeroDie()
  47. {
  48. CombatController.currActiveCombat.CombatHeroController.RemoveHeroHitPoint(_combatHeroEntity.IsEnemy,_combatHeroHitPoints);
  49. }
  50. public void SetPosition(Vector3 pos)
  51. {
  52. GameObjectPool.own.transform.position = pos;
  53. }
  54. public T GetILifetCycleHitPoint<T>(string hitPoinName, bool isStandType, bool isIgnoreHind)
  55. where T : ILifetCycleHitPoint
  56. {
  57. return (T)(object)_combatHeroHitPoints;
  58. }
  59. public T GetMainHotPoin<T>(bool isIgnoreHind) where T : ILifetCycleHitPoint
  60. {
  61. return (T)(object)_combatHeroHitPoints;
  62. }
  63. public void Dispose()
  64. {
  65. GObjectPool.Instance.Recycle(GameObjectPool);
  66. }
  67. }