TimeLineEventLogicBasic.cs 7.0 KB

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