TimeLineEventParticleLogicBasic.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. loopFx.Clear();
  72. if (currTarget != null)
  73. {
  74. currTarget.Dispose();
  75. }
  76. currTarget = null;
  77. }
  78. private void ExecuteFxTarget(BetterList<ILifetCycleHitPoint> combatTarget, int index)
  79. {
  80. if (combatTarget.Count <= index)
  81. {
  82. return;
  83. }
  84. ILifetCycleHitPoint lifeCycle = combatTarget[index];
  85. if (lifeCycle == null)
  86. {
  87. LogTool.Log("一个空的目标");
  88. index++;
  89. ExecuteFxTarget(combatTarget, index);
  90. return;
  91. }
  92. if (!string.IsNullOrEmpty(timeLinePlayFxSerializtion.fxName))
  93. {
  94. ILifetCycleHitPoint fxTarget = null;
  95. Vector3 startPos = Vector3.one;
  96. SpecialDotInfo targetSpecialDotInfo = null;
  97. switch (timeLinePlayFxSerializtion.locationType)
  98. {
  99. case FXLocationType.Oneself:
  100. fxTarget = _castEntity.GetMainHotPoin<ILifetCycleHitPoint>(true);
  101. break;
  102. case FXLocationType.Target:
  103. fxTarget = lifeCycle;
  104. break;
  105. case FXLocationType.CustomTarget:
  106. fxTarget = lifeCycle;
  107. break;
  108. case FXLocationType.SceneZero:
  109. fxTarget = _castEntity.GetMainHotPoin<ILifetCycleHitPoint>(false);
  110. startPos = TimeLineEventLogicGroup.SceneWorldPos();
  111. break;
  112. case FXLocationType.OneselfSpecialDot:
  113. fxTarget = _castEntity.GetMainHotPoin<ILifetCycleHitPoint>(false);
  114. break;
  115. case FXLocationType.TargetSpecialDot:
  116. fxTarget = lifeCycle;
  117. break;
  118. }
  119. if (fxTarget != null)
  120. {
  121. if (!string.IsNullOrEmpty(timeLinePlayFxSerializtion.hitPointGroupName))
  122. {
  123. ILifetCycleHitPoint newHitPoint =
  124. fxTarget.IfLifeCycle.GetILifetCycleHitPoint<ILifetCycleHitPoint>(
  125. timeLinePlayFxSerializtion.hitPointGroupName, true,true);
  126. targetSpecialDotInfo =
  127. newHitPoint.GetSpecialDotInfo(timeLinePlayFxSerializtion.targetSpecialDotName);
  128. }
  129. else
  130. {
  131. targetSpecialDotInfo =
  132. fxTarget.GetSpecialDotInfo(timeLinePlayFxSerializtion.targetSpecialDotName);
  133. }
  134. }
  135. if (timeLinePlayFxSerializtion.isActivityCustomTargetPos&&customizePos!=null&&customizePos.Length>timeLinePlayFxSerializtion.CustomTargetPosIndex)
  136. {
  137. startPos = customizePos[timeLinePlayFxSerializtion.CustomTargetPosIndex];
  138. targetSpecialDotInfo = null;
  139. }
  140. else if (targetSpecialDotInfo != null&&timeLinePlayFxSerializtion.locationType!=FXLocationType.SceneZero)
  141. {
  142. startPos = targetSpecialDotInfo.GetWorlPos();
  143. }
  144. if (timeLinePlayFxSerializtion.isGround)
  145. {
  146. startPos = new Vector3(startPos.x, (float) 0.7f);
  147. }
  148. LoadFx(lifeCycle, fxTarget, startPos,targetSpecialDotInfo);
  149. }
  150. index++;
  151. if (timeLinePlayFxSerializtion.intervalTime > 0)
  152. {
  153. _combatTimer = CombatTimerManager.Instance.AddTimer((float)timeLinePlayFxSerializtion.intervalTime*index,
  154. delegate { });
  155. ExecuteFxTarget(combatTarget, index);
  156. }
  157. else
  158. {
  159. ExecuteFxTarget(combatTarget, index);
  160. }
  161. }
  162. protected void LoadFx(ILifetCycleHitPoint effectTarget, ILifetCycleHitPoint fxTarget, Vector3 startPos,
  163. SpecialDotInfo targetSpecialDotInfo)
  164. {
  165. ITimeLineParticleFactory iTimeLineParticleFactory = TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory;
  166. if (iTimeLineParticleFactory != null)
  167. {
  168. Clock clock = iTimeLineParticleFactory.CreateParticle(this, effectTarget, fxTarget, startPos,targetSpecialDotInfo,
  169. delegate(IGObjectPoolInterface systemPool)
  170. {
  171. ParticleSystemPool pool = systemPool as ParticleSystemPool;
  172. if (pool != null)
  173. {
  174. if (timeLinePlayFxSerializtion.isLoop)
  175. {
  176. loopFx.Add(pool);
  177. }
  178. if (timeLinePlayFxSerializtion.isAttSpeed)
  179. {
  180. ITimeLineParticlePlaySpeed timeLineParticlePlaySpeed =
  181. _castEntity as ITimeLineParticlePlaySpeed;
  182. #if !COMBAT_SERVER
  183. pool.palySpeed = timeLineParticlePlaySpeed.GetCurrPlaySpeed(timeLinePlayFxSerializtion);
  184. #endif
  185. }
  186. else
  187. {
  188. #if !COMBAT_SERVER
  189. pool.palySpeed = (float) 1;
  190. #endif
  191. }
  192. _timeLineEventLogicGroup.OnInitParticleSystemPoolCallBack?.Invoke(pool);
  193. }
  194. });
  195. if (clock != null)
  196. {
  197. loadTask.Add(clock);
  198. }
  199. }
  200. }
  201. }
  202. }