TimeLineEventLogicBasic.cs 6.4 KB

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