TimeLineEventParticleLogicBasic.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using Common.Utility.CombatTimer;
  4. using Fort23.Core;
  5. #if !COMBAT_SERVER
  6. using Fort23.Core;
  7. #endif
  8. using Fort23.UTool;
  9. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  10. #if !COMBAT_SERVER
  11. using UnityEngine;
  12. #endif
  13. namespace UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic
  14. {
  15. public class TimeLineEventParticleLogicBasic : TimeLineEventLogicBasic
  16. {
  17. // private Timer timer;
  18. private List<Clock> loadTask = new List<Clock>();
  19. public List<ParticleSystemPool> loopFx = new List<ParticleSystemPool>();
  20. private CombatTimer _combatTimer;
  21. public TimeLinePlayFxSerializtion timeLinePlayFxSerializtion
  22. {
  23. get { return mTimeLineAssetSerialization as TimeLinePlayFxSerializtion; }
  24. }
  25. protected override void ProSetCombatInfo()
  26. {
  27. }
  28. protected override void ProEnter()
  29. {
  30. // ITimeLineTriggerEvent trigger = _targetEntity as ITimeLineTriggerEvent;
  31. // if (trigger != null)
  32. {
  33. BetterList<ILifetCycleHitPoint> timeLineEntities = GetSkillTarget();
  34. ExecuteFxTarget(timeLineEntities, 0);
  35. }
  36. }
  37. protected override void ProLeave()
  38. {
  39. }
  40. protected override void ProTimeUpdate()
  41. {
  42. }
  43. protected override void ProBreakTimeLine()
  44. {
  45. for (int i = 0; i < loadTask.Count; i++)
  46. {
  47. loadTask[i].Dispose();
  48. }
  49. CombatTimerManager.Instance.RemoveTimer(_combatTimer);
  50. _combatTimer = null;
  51. CloseLoopFx();
  52. loadTask.Clear();
  53. }
  54. public void CloseLoopFx()
  55. {
  56. for (int i = 0; i < loopFx.Count; i++)
  57. {
  58. GObjectPool.Instance.Recycle(loopFx[i]);
  59. }
  60. loopFx.Clear();
  61. }
  62. protected override void ProDispose()
  63. {
  64. for (int i = 0; i < loadTask.Count; i++)
  65. {
  66. loadTask[i].Dispose();
  67. }
  68. CombatTimerManager.Instance.RemoveTimer(_combatTimer);
  69. _combatTimer = null;
  70. loadTask.Clear();
  71. if (currTarget != null)
  72. {
  73. currTarget.Dispose();
  74. }
  75. currTarget = null;
  76. }
  77. private void ExecuteFxTarget(BetterList<ILifetCycleHitPoint> combatTarget, int index)
  78. {
  79. if (combatTarget.Count <= index)
  80. {
  81. return;
  82. }
  83. ILifetCycleHitPoint lifeCycle = combatTarget[index];
  84. if (lifeCycle == null)
  85. {
  86. LogTool.Log("一个空的目标");
  87. index++;
  88. ExecuteFxTarget(combatTarget, index);
  89. return;
  90. }
  91. if (!string.IsNullOrEmpty(timeLinePlayFxSerializtion.fxName))
  92. {
  93. ILifetCycleHitPoint fxTarget = null;
  94. Vector3 startPos = Vector3.one;
  95. SpecialDotInfo targetSpecialDotInfo = null;
  96. switch (timeLinePlayFxSerializtion.locationType)
  97. {
  98. case FXLocationType.Oneself:
  99. fxTarget = _castEntity.GetMainHotPoin<ILifetCycleHitPoint>(true);
  100. break;
  101. case FXLocationType.Target:
  102. fxTarget = lifeCycle;
  103. break;
  104. case FXLocationType.CustomTarget:
  105. fxTarget = lifeCycle;
  106. break;
  107. case FXLocationType.SceneZero:
  108. fxTarget = _castEntity.GetMainHotPoin<ILifetCycleHitPoint>(false);
  109. startPos = TimeLineEventLogicGroup.SceneWorldPos();
  110. break;
  111. case FXLocationType.OneselfSpecialDot:
  112. fxTarget = _castEntity.GetMainHotPoin<ILifetCycleHitPoint>(false);
  113. break;
  114. case FXLocationType.TargetSpecialDot:
  115. fxTarget = lifeCycle;
  116. break;
  117. }
  118. if (fxTarget != null)
  119. {
  120. if (!string.IsNullOrEmpty(timeLinePlayFxSerializtion.hitPointGroupName))
  121. {
  122. ILifetCycleHitPoint newHitPoint =
  123. fxTarget.IfLifeCycle.GetILifetCycleHitPoint<ILifetCycleHitPoint>(
  124. timeLinePlayFxSerializtion.hitPointGroupName, true,true);
  125. targetSpecialDotInfo =
  126. newHitPoint.GetSpecialDotInfo(timeLinePlayFxSerializtion.targetSpecialDotName);
  127. }
  128. else
  129. {
  130. targetSpecialDotInfo =
  131. fxTarget.GetSpecialDotInfo(timeLinePlayFxSerializtion.targetSpecialDotName);
  132. }
  133. }
  134. if (timeLinePlayFxSerializtion.isActivityCustomTargetPos&&customizePos!=null&&customizePos.Length>timeLinePlayFxSerializtion.CustomTargetPosIndex)
  135. {
  136. startPos = customizePos[timeLinePlayFxSerializtion.CustomTargetPosIndex];
  137. targetSpecialDotInfo = null;
  138. }
  139. else if (targetSpecialDotInfo != null&&timeLinePlayFxSerializtion.locationType!=FXLocationType.SceneZero)
  140. {
  141. startPos = targetSpecialDotInfo.GetWorlPos();
  142. }
  143. if (timeLinePlayFxSerializtion.isGround)
  144. {
  145. startPos = new Vector3(startPos.x, (float) 0.7f);
  146. }
  147. LoadFx(lifeCycle, fxTarget, startPos,targetSpecialDotInfo);
  148. }
  149. index++;
  150. if (timeLinePlayFxSerializtion.intervalTime > 0)
  151. {
  152. _combatTimer = CombatTimerManager.Instance.AddTimer((float)timeLinePlayFxSerializtion.intervalTime*index,
  153. delegate { });
  154. ExecuteFxTarget(combatTarget, index);
  155. }
  156. else
  157. {
  158. ExecuteFxTarget(combatTarget, index);
  159. }
  160. }
  161. protected void LoadFx(ILifetCycleHitPoint effectTarget, ILifetCycleHitPoint fxTarget, Vector3 startPos,
  162. SpecialDotInfo targetSpecialDotInfo)
  163. {
  164. ITimeLineParticleFactory iTimeLineParticleFactory = TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory;
  165. if (iTimeLineParticleFactory != null)
  166. {
  167. Clock clock = iTimeLineParticleFactory.CreateParticle(this, effectTarget, fxTarget, startPos,targetSpecialDotInfo,
  168. delegate(IGObjectPoolInterface systemPool)
  169. {
  170. ParticleSystemPool pool = systemPool as ParticleSystemPool;
  171. if (pool != null)
  172. {
  173. if (IsDis)
  174. {
  175. GObjectPool.Instance.Recycle(pool);
  176. return;
  177. }
  178. if (timeLinePlayFxSerializtion.isLoop)
  179. {
  180. loopFx.Add(pool);
  181. }
  182. if (timeLinePlayFxSerializtion.isAttSpeed)
  183. {
  184. ITimeLineParticlePlaySpeed timeLineParticlePlaySpeed =
  185. _castEntity as ITimeLineParticlePlaySpeed;
  186. #if !COMBAT_SERVER
  187. pool.palySpeed = timeLineParticlePlaySpeed.GetCurrPlaySpeed(timeLinePlayFxSerializtion);
  188. #endif
  189. }
  190. else
  191. {
  192. #if !COMBAT_SERVER
  193. pool.palySpeed = (float) 1;
  194. #endif
  195. }
  196. _timeLineEventLogicGroup.OnInitParticleSystemPoolCallBack?.Invoke(pool);
  197. }
  198. });
  199. if (clock != null)
  200. {
  201. loadTask.Add(clock);
  202. }
  203. }
  204. }
  205. }
  206. }