TimeLineEventLogicBasic.cs 7.1 KB

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