TimeLineEventParticleLogicBasic.cs 7.8 KB

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