TimeLineEventLogicBasic.cs 7.1 KB

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