TimeLineAlertLogic.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using Core.Triiger;
  2. using UnityEngine;
  3. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  4. namespace UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic
  5. {
  6. public class TimeLineAlertLogic : TimeLineEventLogicBasic
  7. {
  8. private IUnRegister _enterRegister;
  9. private IUnRegister _exitRegister;
  10. protected GameObject _gameObject;
  11. protected override void ProSetCombatInfo()
  12. {
  13. }
  14. protected override void ProEnter()
  15. {
  16. _enterRegister?.UnRegister();
  17. _exitRegister?.UnRegister();
  18. _enterRegister = null;
  19. _exitRegister = null;
  20. TimeLineAlertSeriailztion timeLineAlertSeriailztion =
  21. mTimeLineAssetSerialization as TimeLineAlertSeriailztion;
  22. if (!string.IsNullOrEmpty(timeLineAlertSeriailztion.guid))
  23. {
  24. SpecialDotInfo specialDotInfo = castEntity.GetMainHotPoin<ILifetCycleHitPoint>(true)
  25. .GetSpecialDotInfo(timeLineAlertSeriailztion.guid);
  26. _gameObject = specialDotInfo.targetTran.gameObject;
  27. _gameObject.SetActive(false);
  28. _enterRegister = specialDotInfo.targetTran.gameObject.OnTriggerEnterEvent(OnTriggerEnterEvent);
  29. _exitRegister = specialDotInfo.targetTran.gameObject.OnTriggerExitEvent(OnTriggerExitEvent);
  30. ITimeLineAlertTargetEnter timeLineAlertTarget =
  31. _timeLineTriggerEntity as ITimeLineAlertTargetEnter;
  32. if (timeLineAlertTarget != null)
  33. {
  34. timeLineAlertTarget.InitAlert(timeLineAlertSeriailztion,specialDotInfo.targetTran.gameObject);
  35. }
  36. specialDotInfo.targetTran.gameObject.SetActive(true);
  37. }
  38. }
  39. protected void OnTriggerEnterEvent(Collider collider)
  40. {
  41. TimeLineAlertSeriailztion timeLineAlertSeriailztion =
  42. mTimeLineAssetSerialization as TimeLineAlertSeriailztion;
  43. ITimeLineAlertTargetEnter timeLineAlertTarget =
  44. _timeLineTriggerEntity as ITimeLineAlertTargetEnter;
  45. if (timeLineAlertTarget != null)
  46. {
  47. ExitEventGameObject exitEventGameObject= collider.gameObject.GetOrAddComponent<ExitEventGameObject>();
  48. exitEventGameObject.Collider = collider;
  49. exitEventGameObject.OnCollisionExitEvent=(OnTriggerExitEvent);
  50. timeLineAlertTarget.Enter(timeLineAlertSeriailztion, collider,_gameObject);
  51. }
  52. }
  53. protected void OnTriggerExitEvent(Collider collider)
  54. {
  55. TimeLineAlertSeriailztion timeLineAlertSeriailztion =
  56. mTimeLineAssetSerialization as TimeLineAlertSeriailztion;
  57. ITimeLineAlertTargetEnter timeLineAlertTarget =
  58. _timeLineTriggerEntity as ITimeLineAlertTargetEnter;
  59. if (timeLineAlertTarget != null)
  60. {
  61. ExitEventGameObject exitEventGameObject= collider.gameObject.GetOrAddComponent<ExitEventGameObject>();
  62. if (exitEventGameObject.OnCollisionExitEvent == null)
  63. {
  64. return;
  65. }
  66. exitEventGameObject.Collider = null;
  67. exitEventGameObject.OnCollisionExitEvent = null;
  68. timeLineAlertTarget.Leave(timeLineAlertSeriailztion, collider,_gameObject);
  69. }
  70. }
  71. protected override void ProLeave()
  72. {
  73. TimeLineAlertSeriailztion timeLineAlertSeriailztion =
  74. mTimeLineAssetSerialization as TimeLineAlertSeriailztion;
  75. if (timeLineAlertSeriailztion.manualClose)
  76. {
  77. return;
  78. }
  79. if (!string.IsNullOrEmpty(timeLineAlertSeriailztion.guid))
  80. {
  81. SpecialDotInfo specialDotInfo = castEntity.GetMainHotPoin<ILifetCycleHitPoint>(true)
  82. .GetSpecialDotInfo(timeLineAlertSeriailztion.guid);
  83. specialDotInfo.targetTran.gameObject.SetActive(false);
  84. ITimeLineAlertTargetEnter timeLineAlertTarget =
  85. _timeLineTriggerEntity as ITimeLineAlertTargetEnter;
  86. if (timeLineAlertTarget != null)
  87. {
  88. timeLineAlertTarget.LeaveAlert(timeLineAlertSeriailztion,specialDotInfo.targetTran.gameObject);
  89. }
  90. }
  91. _enterRegister?.UnRegister();
  92. _exitRegister?.UnRegister();
  93. _enterRegister = null;
  94. _exitRegister = null;
  95. }
  96. protected override void ProTimeUpdate()
  97. {
  98. }
  99. protected override void ProBreakTimeLine()
  100. {
  101. TimeLineAlertSeriailztion timeLineAlertSeriailztion =
  102. mTimeLineAssetSerialization as TimeLineAlertSeriailztion;
  103. if (!string.IsNullOrEmpty(timeLineAlertSeriailztion.guid))
  104. {
  105. SpecialDotInfo specialDotInfo = castEntity.GetMainHotPoin<ILifetCycleHitPoint>(true)
  106. .GetSpecialDotInfo(timeLineAlertSeriailztion.guid);
  107. specialDotInfo.targetTran.gameObject.SetActive(false);
  108. ITimeLineAlertTargetEnter timeLineAlertTarget =
  109. _timeLineTriggerEntity as ITimeLineAlertTargetEnter;
  110. if (timeLineAlertTarget != null)
  111. {
  112. timeLineAlertTarget.LeaveAlert(timeLineAlertSeriailztion,specialDotInfo.targetTran.gameObject);
  113. }
  114. }
  115. _enterRegister?.UnRegister();
  116. _exitRegister?.UnRegister();
  117. _enterRegister = null;
  118. _exitRegister = null;
  119. }
  120. protected override void ProDispose()
  121. {
  122. _enterRegister?.UnRegister();
  123. _exitRegister?.UnRegister();
  124. _enterRegister = null;
  125. _exitRegister = null;
  126. }
  127. }
  128. }