FxAILogicBasic.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. using System;
  2. using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;
  3. using Fort23.Common;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using GameLogic.Combat.CombatTool;
  7. #if !COMBAT_SERVER
  8. using UnityEngine;
  9. #endif
  10. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  11. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic;
  12. namespace Common.Combat.FxAILogic
  13. {
  14. public abstract class FxAILogicBasic : MonoBehaviour, IDisposable, ITimelineFxLogic
  15. {
  16. private TimeLineEventParticleLogicBasic _timeLineEventParticleLogicBasic;
  17. private ILifetCycleHitPoint _attTarget;
  18. [Header("碰撞时的特效")] public string hitFxName;
  19. public ILifetCycleHitPoint AttTarget
  20. {
  21. get { return _attTarget; }
  22. }
  23. public CombatHeroEntity CombatHeroEntity
  24. {
  25. get { return _combatHeroEntity; }
  26. }
  27. private CombatHeroEntity _combatHeroEntity;
  28. public TimeLineEventParticleLogicBasic TimeLineEventParticleLogicBasic
  29. {
  30. get { return _timeLineEventParticleLogicBasic; }
  31. }
  32. public IGObjectPoolInterface ObjectPoolInterface;
  33. public bool isPenetrate;
  34. [Header("是否使用自定义目标结束点")] public bool isUseCustomTargetEndPos;
  35. [Header("结束点的下标")] public int customTargetEndPosIndex;
  36. /// <summary>
  37. /// 开始点
  38. /// </summary>
  39. protected Vector3 startPos;
  40. public Vector3 CurrPos
  41. {
  42. get { return _currPos; }
  43. }
  44. /// <summary>
  45. /// 当前Obj的位置
  46. /// </summary>
  47. protected Vector3 _currPos;
  48. protected Vector3 rotation;
  49. protected SpecialDotInfo specialDotInfo;
  50. protected float currTime;
  51. public TriggerData triggerData;
  52. protected bool isNotCanTriggerGround;
  53. protected bool _isUpdateBasic;
  54. public void Init(Vector3 startPos,
  55. TimeLineEventParticleLogicBasic timeLineEventParticleLogicBasic, ILifetCycleHitPoint attTarget,
  56. SpecialDotInfo specialDotInfo = null)
  57. {
  58. if (timeLineEventParticleLogicBasic.castEntity == null)
  59. {
  60. Dispose();
  61. return;
  62. }
  63. _currPos = startPos;
  64. this.startPos = startPos;
  65. this._timeLineEventParticleLogicBasic = timeLineEventParticleLogicBasic;
  66. this._attTarget = attTarget;
  67. _combatHeroEntity = timeLineEventParticleLogicBasic.castEntity.This<CombatHeroEntity>();
  68. this.specialDotInfo = specialDotInfo;
  69. ITimeLineTriggerEvent trigger =
  70. timeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
  71. if (trigger != null)
  72. {
  73. trigger.TimelineFxLogicInit(timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.groupName, this,
  74. triggerData);
  75. }
  76. triggerData = timeLineEventParticleLogicBasic.extraData;
  77. triggerData.TrggerObject = this;
  78. _isUpdateBasic = true;
  79. ProInit();
  80. }
  81. public void SetAIMonoObj(IGObjectPoolInterface poolInterface)
  82. {
  83. this.ObjectPoolInterface = poolInterface;
  84. }
  85. // private void Detection()
  86. // {
  87. // if (_updateCount % 2 != 0)
  88. // {
  89. // return;
  90. // }
  91. //
  92. // ProDetection();
  93. // }
  94. //
  95. // protected virtual void ProDetection()
  96. // {
  97. // }
  98. protected void Hit(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
  99. SpecialDotInfo targetSpecialDotInfo)
  100. {
  101. if (string.IsNullOrEmpty(fxName))
  102. {
  103. return;
  104. }
  105. TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(fxName, startPos, fxTarget,
  106. isRotate,
  107. targetSpecialDotInfo, delegate(ParticleSystemPool pool)
  108. {
  109. #if !COMBAT_SERVER
  110. // if (ObjectPoolInterface != null&&pool.own!=null)
  111. // {
  112. // FxColorAlter colorAlter = ObjectPoolInterface.own.GetComponent<FxColorAlter>();
  113. // if (colorAlter != null)
  114. // {
  115. // FxColorAlter colorAlter2 = pool.own.GetComponent<FxColorAlter>();
  116. // if (colorAlter2 == null)
  117. // {
  118. // colorAlter2 = pool.own.AddComponent<FxColorAlter>();
  119. // }
  120. //
  121. // colorAlter2.AlterColor(colorAlter.currValue);
  122. // }
  123. // }
  124. #endif
  125. });
  126. }
  127. public void CombatUpdate(float time)
  128. {
  129. if (!_isUpdateBasic)
  130. {
  131. return;
  132. }
  133. ProCombatUpdate(time);
  134. if (_timeLineEventParticleLogicBasic == null)
  135. {
  136. return;
  137. }
  138. // Detection();
  139. UnityRenderUpdate(time);
  140. }
  141. public void UnityRenderUpdate(float time)
  142. {
  143. ProUnityRenderUpdate(time);
  144. }
  145. public void Dispose()
  146. {
  147. if (_timeLineEventParticleLogicBasic == null)
  148. {
  149. return;
  150. }
  151. GObjectPool.Instance.Recycle(ObjectPoolInterface);
  152. CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveFxAILogicBasic(this);
  153. ProDispose();
  154. // timeLineEventParticleLogicBasic?.Dispose();
  155. ObjectPoolInterface = null;
  156. _timeLineEventParticleLogicBasic = null;
  157. _attTarget = null;
  158. ObjectPoolInterface = null;
  159. // _fxAiDataBasic = null;
  160. _isUpdateBasic = false;
  161. // UnityRenderUpdateComponent.Instance.RemoveICombatUpdate(this);
  162. // CombatFactoryTool.Instance.Recycle(scName, this);
  163. }
  164. protected virtual void ProInit()
  165. {
  166. }
  167. protected virtual void ProCombatUpdate(float time)
  168. {
  169. }
  170. protected virtual void ProUnityRenderUpdate(float time)
  171. {
  172. }
  173. protected virtual void ProDispose()
  174. {
  175. }
  176. }
  177. }