GameTimeLineParticleFactory.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Fort23.Common;
  5. using Fort23.Core;
  6. using Fort23.UTool;
  7. using UnityEngine;
  8. using UnityEngine.Rendering;
  9. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  10. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic;
  11. public class GameTimeLineParticleFactory : ITimeLineParticleFactory
  12. {
  13. protected List<CombatParticleSystemPool> allCombatParticleSystem =
  14. new List<CombatParticleSystemPool>();
  15. public Clock CreateParticle(TimeLineEventParticleLogicBasic timeLineEventParticleLogicBasic,
  16. ILifetCycleHitPoint effectTarget,
  17. ILifetCycleHitPoint fxTarget, Vector3 startPos, SpecialDotInfo targetSpecialDotInfo,
  18. Action<IGObjectPoolInterface> callBack)
  19. {
  20. Clock clock = CreateParticle(timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.fxName, startPos,
  21. fxTarget,
  22. false, targetSpecialDotInfo, delegate(ParticleSystemPool combatParticleSystemPool)
  23. {
  24. CombatParticleSystemPool pool = combatParticleSystemPool as CombatParticleSystemPool;
  25. #if !COMBAT_SERVER
  26. pool.InitCombatParticleSystem();
  27. #endif
  28. if (targetSpecialDotInfo != null)
  29. {
  30. #if !COMBAT_SERVER
  31. // CombatHeroEntity heroEntity = targetSpecialDotInfo.heroEntity as CombatHeroEntity;
  32. // if (heroEntity.CombatHeroTransform.iGObjectPoolInterface == null)
  33. // {
  34. // return;
  35. // }
  36. #endif
  37. // if (!timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.isActivityCustomTargetPos)
  38. // {
  39. // startPos = targetSpecialDotInfo.GetWorlPos();
  40. // }
  41. #if !COMBAT_SERVER
  42. if (!timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.isNotRotate)
  43. {
  44. pool.transform.eulerAngles = targetSpecialDotInfo.GetEulerAngles();
  45. pool.isNotRotion = false;
  46. }
  47. else
  48. {
  49. pool.isNotRotion = true;
  50. }
  51. // if (heroEntity != null)
  52. // {
  53. // pool.transform.SetParent(heroEntity.CombatHeroTransform.iGObjectPoolInterface.own.transform);
  54. // }
  55. // else
  56. // {
  57. // pool.transform.SetParent(targetSpecialDotInfo.targetTran);
  58. // }
  59. #endif
  60. }
  61. else
  62. {
  63. }
  64. #if !COMBAT_SERVER
  65. pool.gameObject.SetActive(false);
  66. pool.transform.position = startPos;
  67. if (timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.isFollowTarget &&
  68. timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.locationType !=
  69. FXLocationType.SceneZero)
  70. {
  71. pool.transform.localEulerAngles = Vector3.zero;
  72. pool.targetSpecialDotInfo = targetSpecialDotInfo;
  73. }
  74. else
  75. {
  76. // pool.transform.SetParent(null);
  77. pool.targetSpecialDotInfo = null;
  78. }
  79. #endif
  80. // if (fxAiDataBasic != null)
  81. // {
  82. // if (CombatManager.Instance.currFrame != initFrame)
  83. // {
  84. // LogTool.Error(
  85. // $"战斗中特效没有预加载 {CombatManager.Instance.currFrame - initFrame} {timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.fxName}");
  86. // }
  87. //
  88. // FxAILogicBasic fxAILogicBasic = CreateFxAILogicBasic(fxAiDataBasic);
  89. // if (fxAILogicBasic != null)
  90. // {
  91. // if (!allFxAiLogicBasic.Contains(fxAILogicBasic))
  92. // {
  93. // allFxAiLogicBasic.Add(fxAILogicBasic);
  94. // }
  95. //
  96. // fxAILogicBasic.SetAIMonoObj(combatParticleSystemPool);
  97. // fxAILogicBasic.Init(startPos, fxAiDataBasic, timeLineEventParticleLogicBasic, effectTarget,
  98. // targetSpecialDotInfo);
  99. // }
  100. // }
  101. #if !COMBAT_SERVER
  102. pool.gameObject.SetActive(true);
  103. #endif
  104. callBack?.Invoke(combatParticleSystemPool);
  105. });
  106. return clock;
  107. }
  108. public Clock CreateParticle(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
  109. SpecialDotInfo targetSpecialDotInfo, Action<ParticleSystemPool> callBack, bool isNotLoadFx = false)
  110. {
  111. #if !COMBAT_SERVER
  112. Clock clock = ClockPool.GetClock();
  113. CTask<CombatParticleSystemPool> task = GObjectPool.Instance.FetchAsync(fxName + ".prefab",
  114. delegate(CombatParticleSystemPool pool)
  115. {
  116. if (pool == null)
  117. {
  118. return;
  119. }
  120. // if (!isActive)
  121. // {
  122. // GObjectPool.Instance.RecycleForDestroy(pool);
  123. // return;
  124. // }
  125. if (!allCombatParticleSystem.Contains(pool))
  126. {
  127. allCombatParticleSystem.Add(pool);
  128. }
  129. else
  130. {
  131. LogTool.Error("添加重复");
  132. }
  133. //
  134. // if (targetSpecialDotInfo != null && targetSpecialDotInfo.rootTrnsform != null)
  135. // {
  136. // SortingGroup sortingGroup = targetSpecialDotInfo.rootTrnsform.GetSortingGroup();
  137. // if (sortingGroup != null)
  138. // {
  139. // pool.SetRootSortingGroup(sortingGroup);
  140. // }
  141. // else
  142. // {
  143. // pool.SetOder(0, "Hero");
  144. // }
  145. // }
  146. // else
  147. // {
  148. // pool.SetOder(10000, "Hero");
  149. // }
  150. if (isRotate && fxTarget != null)
  151. {
  152. SpecialDotInfo specialDotInfo = fxTarget.GetSpecialDotInfo(null);
  153. if (specialDotInfo != null)
  154. {
  155. pool.transform.eulerAngles = specialDotInfo.GetEulerAngles();
  156. }
  157. }
  158. float size = 1;
  159. // if (fxTarget != null)
  160. // {
  161. // CombatHeroEntity combatHeroEntity = fxTarget.IfLifeCycle.This<CombatHeroEntity>();
  162. // if (combatHeroEntity != null)
  163. // {
  164. // HeroGameObjectConfig heroGameObjectConfig =
  165. // combatHeroEntity.HeroGameObjectConfig;
  166. // if (heroGameObjectConfig != null)
  167. // {
  168. // size = heroGameObjectConfig.size;
  169. // }
  170. // }
  171. // }
  172. pool.SetSize(size);
  173. pool.own.transform.position = startPos;
  174. callBack?.Invoke(pool);
  175. }, clock);
  176. return clock;
  177. #else
  178. callBack?.Invoke(new CombatParticleSystemPool());
  179. return null;
  180. #endif
  181. }
  182. }