TimeLineEventLogicBasic.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using CombatLibrary.CombatLibrary.CombatCore;
  5. using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;
  6. using UnityEngine;
  7. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  8. public abstract class TimeLineEventLogicBasic : IDisposable
  9. {
  10. public TimeLineAssetSerialization timeLineAssetSerialization
  11. {
  12. get { return mTimeLineAssetSerialization; }
  13. }
  14. protected TimeLineAssetSerialization mTimeLineAssetSerialization;
  15. /// <summary>
  16. /// 是否进入
  17. /// </summary>
  18. protected bool IsEnter;
  19. protected bool IsLeave;
  20. public ILifeCycle castEntity
  21. {
  22. get { return _castEntity; }
  23. }
  24. public ITimeLineTriggerEntity ITimeLineTriggerEntity
  25. {
  26. get { return _timeLineTriggerEntity; }
  27. }
  28. public TriggerData extraData
  29. {
  30. get { return _extraData; }
  31. set { _extraData = value; }
  32. }
  33. /// <summary>
  34. /// 施放者(谁施放的这个效果 (EntityBasic))
  35. /// </summary>
  36. protected ILifeCycle _castEntity;
  37. /// <summary>
  38. /// 触发者(谁触发的这个效果(skill))
  39. /// </summary>
  40. protected ITimeLineTriggerEntity _timeLineTriggerEntity;
  41. protected BetterList<ILifetCycleHitPoint> currTarget;
  42. protected TriggerData _extraData;
  43. public Vector3[] customizePos
  44. {
  45. get { return _customizePos; }
  46. }
  47. protected Vector3[] _customizePos;
  48. protected TimeLineEventLogicGroupBasic _timeLineEventLogicGroup;
  49. public TimeLineEventLogicGroupBasic TimeLineEventLogicGroup
  50. {
  51. get { return _timeLineEventLogicGroup; }
  52. }
  53. public void InitEventLogic(TimeLineEventLogicGroupBasic timeLineEventLogicGroup,
  54. TimeLineAssetSerialization timeLineAssetSerialization)
  55. {
  56. mTimeLineAssetSerialization = timeLineAssetSerialization;
  57. this._timeLineEventLogicGroup = timeLineEventLogicGroup;
  58. }
  59. /// <summary>
  60. /// timeline触发后持续更新
  61. /// </summary>
  62. /// <param name="time">当前时间线从执行到现在的时间</param>
  63. public void TimeUpdate(float time)
  64. {
  65. if (time >= mTimeLineAssetSerialization.startTime)
  66. {
  67. if (!IsEnter)
  68. {
  69. IsEnter = true;
  70. Enter();
  71. }
  72. }
  73. ProTimeUpdate();
  74. if (time >= mTimeLineAssetSerialization.endTime)
  75. {
  76. if (!IsLeave)
  77. {
  78. IsLeave = true;
  79. Leave();
  80. }
  81. }
  82. }
  83. protected void Enter()
  84. {
  85. ProEnter();
  86. }
  87. protected void Leave()
  88. {
  89. ProLeave();
  90. }
  91. public void Pause()
  92. {
  93. ProPause();
  94. }
  95. protected virtual void ProPause()
  96. {
  97. }
  98. public void SetCombatInfo(ILifeCycle castEntity, ITimeLineTriggerEntity targetEntity,
  99. BetterList<ILifetCycleHitPoint> currTarget,
  100. TriggerData extraData,
  101. Vector3[] customizePos)
  102. {
  103. this._castEntity = castEntity;
  104. this._timeLineTriggerEntity = targetEntity;
  105. this.currTarget = currTarget;
  106. this._extraData = extraData;
  107. this._customizePos = customizePos;
  108. ProSetCombatInfo();
  109. }
  110. ///// <summary>m
  111. ///// 关闭FXinfo,隐藏掉改info创建并在使用的特效
  112. ///// </summary>
  113. public void BreakTimeLine()
  114. {
  115. if (currTarget != null)
  116. {
  117. currTarget.Clear();
  118. }
  119. ProBreakTimeLine();
  120. Dispose();
  121. }
  122. public void Dispose()
  123. {
  124. if (!IsLeave && IsEnter)
  125. {
  126. IsLeave = true;
  127. Leave();
  128. }
  129. ProDispose();
  130. }
  131. public BetterList<ILifetCycleHitPoint> GetSkillTarget()
  132. {
  133. if (mTimeLineAssetSerialization.targetEntityType.HasFlag(FXTargetType.Oneself))
  134. {
  135. BetterList<ILifetCycleHitPoint> target = CombatListPool<ILifetCycleHitPoint>.Instance.Get();
  136. target.Add(_castEntity.GetMainHotPoin<ILifetCycleHitPoint>(true));
  137. return target;
  138. }
  139. else
  140. {
  141. if (currTarget != null && currTarget.Count > 0)
  142. {
  143. return FilterTargetForCombat(currTarget);
  144. }
  145. if (_timeLineTriggerEntity == null)
  146. {
  147. return new BetterList<ILifetCycleHitPoint>(1);
  148. }
  149. ITimeLineTargetEntity timeLineTargetEntity = _timeLineTriggerEntity as ITimeLineTargetEntity;
  150. if (timeLineTargetEntity == null)
  151. {
  152. return new BetterList<ILifetCycleHitPoint>(1);
  153. }
  154. currTarget = CombatListPool<ILifetCycleHitPoint>.Instance.Get();
  155. ILifetCycleHitPoint[] getTarget = timeLineTargetEntity.GetTineLineTargetEntity(this);
  156. currTarget.AddRange(getTarget);
  157. getTarget = currTarget.ToArray();
  158. if ((int)mTimeLineAssetSerialization.targetEntityType != 2)
  159. {
  160. ILifetCycleHitPoint[] point =
  161. timeLineTargetEntity.FilterTarget(this, mTimeLineAssetSerialization.targetEntityType, getTarget);
  162. currTarget.Clear();
  163. currTarget.AddRange(point);
  164. }
  165. return FilterTargetForCombat(currTarget);
  166. }
  167. }
  168. private BetterList<ILifetCycleHitPoint> FilterTargetForCombat(BetterList<ILifetCycleHitPoint> point)
  169. {
  170. ITimeLineTargetEntity timeLineTargetEntity = _timeLineTriggerEntity as ITimeLineTargetEntity;
  171. if (timeLineTargetEntity == null)
  172. {
  173. return point;
  174. }
  175. ILifetCycleHitPoint[] lifetCycleHitPoints =
  176. timeLineTargetEntity.FilterTargetForCombat(this, mTimeLineAssetSerialization.targetEntityType,
  177. point.ToArray());
  178. point.Clear();
  179. point.AddRange(lifetCycleHitPoints);
  180. return point;
  181. }
  182. protected abstract void ProSetCombatInfo();
  183. protected abstract void ProEnter();
  184. protected abstract void ProLeave();
  185. protected abstract void ProTimeUpdate();
  186. protected abstract void ProBreakTimeLine();
  187. protected virtual void ProDispose()
  188. {
  189. this._timeLineTriggerEntity = null;
  190. this._castEntity = null;
  191. this.currTarget = null;
  192. this._extraData = default;
  193. this._customizePos = null;
  194. }
  195. }