CombatHeroGameObject.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 Vector3 position
  16. {
  17. get { return GameObjectPool.own.transform.position; }
  18. }
  19. public Quaternion rotation
  20. {
  21. get { return GameObjectPool.own.transform.rotation; }
  22. set { GameObjectPool.own.transform.rotation=value; }
  23. }
  24. private CombatHeroEntity _combatHeroEntity;
  25. private CombatHeroHitPoint _combatHeroHitPoints = new CombatHeroHitPoint();
  26. public Transform hpTransform;
  27. public void Init(CombatHeroEntity combatHeroEntity, GameObjectPool gameObjectPool)
  28. {
  29. _combatHeroEntity = combatHeroEntity;
  30. GameObjectPool = gameObjectPool;
  31. SetGameObject(gameObjectPool);
  32. }
  33. public void SetGameObject(GameObjectPool gameObjectPool)
  34. {
  35. hpTransform = GameObjectPool.own.transform.Find("hp");
  36. if (hpTransform == null)
  37. {
  38. hpTransform = GameObjectPool.own.transform;
  39. }
  40. GameObjectPool = gameObjectPool;
  41. HitPointMono hitPointMonos = GameObjectPool.own.GetComponentInChildren<HitPointMono>(true);
  42. HitPointMono hitPointMono = hitPointMonos;
  43. _combatHeroHitPoints = new CombatHeroHitPoint();
  44. _combatHeroHitPoints.Init(_combatHeroEntity, hitPointMono);
  45. CombatController.currActiveCombat.CombatHeroController.AddHeroHitPoint(_combatHeroEntity.IsEnemy,_combatHeroHitPoints);
  46. }
  47. public void HeroDie()
  48. {
  49. CombatController.currActiveCombat.CombatHeroController.RemoveHeroHitPoint(_combatHeroEntity.IsEnemy,_combatHeroHitPoints);
  50. }
  51. public void SetPosition(Vector3 pos)
  52. {
  53. GameObjectPool.own.transform.position = pos;
  54. }
  55. public T GetILifetCycleHitPoint<T>(string hitPoinName, bool isStandType, bool isIgnoreHind)
  56. where T : ILifetCycleHitPoint
  57. {
  58. return (T)(object)_combatHeroHitPoints;
  59. }
  60. public T GetMainHotPoin<T>(bool isIgnoreHind) where T : ILifetCycleHitPoint
  61. {
  62. return (T)(object)_combatHeroHitPoints;
  63. }
  64. public void Dispose()
  65. {
  66. GObjectPool.Instance.Recycle(GameObjectPool);
  67. }
  68. }