FxAILogicBasic.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. _currPos = startPos;
  59. this.startPos = startPos;
  60. this._timeLineEventParticleLogicBasic = timeLineEventParticleLogicBasic;
  61. this._attTarget = attTarget;
  62. _combatHeroEntity = timeLineEventParticleLogicBasic.castEntity.This<CombatHeroEntity>();
  63. this.specialDotInfo = specialDotInfo;
  64. ITimeLineTriggerEvent trigger =
  65. timeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
  66. if (trigger != null)
  67. {
  68. trigger.TimelineFxLogicInit(timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.groupName, this,
  69. triggerData);
  70. }
  71. triggerData = timeLineEventParticleLogicBasic.extraData;
  72. triggerData.TrggerObject = this;
  73. _isUpdateBasic = true;
  74. ProInit();
  75. }
  76. public void SetAIMonoObj(IGObjectPoolInterface poolInterface)
  77. {
  78. this.ObjectPoolInterface = poolInterface;
  79. }
  80. // private void Detection()
  81. // {
  82. // if (_updateCount % 2 != 0)
  83. // {
  84. // return;
  85. // }
  86. //
  87. // ProDetection();
  88. // }
  89. //
  90. // protected virtual void ProDetection()
  91. // {
  92. // }
  93. protected void Hit(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
  94. SpecialDotInfo targetSpecialDotInfo)
  95. {
  96. if (string.IsNullOrEmpty(fxName))
  97. {
  98. return;
  99. }
  100. TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(fxName, startPos, fxTarget,
  101. isRotate,
  102. targetSpecialDotInfo, delegate(ParticleSystemPool pool)
  103. {
  104. #if !COMBAT_SERVER
  105. // if (ObjectPoolInterface != null&&pool.own!=null)
  106. // {
  107. // FxColorAlter colorAlter = ObjectPoolInterface.own.GetComponent<FxColorAlter>();
  108. // if (colorAlter != null)
  109. // {
  110. // FxColorAlter colorAlter2 = pool.own.GetComponent<FxColorAlter>();
  111. // if (colorAlter2 == null)
  112. // {
  113. // colorAlter2 = pool.own.AddComponent<FxColorAlter>();
  114. // }
  115. //
  116. // colorAlter2.AlterColor(colorAlter.currValue);
  117. // }
  118. // }
  119. #endif
  120. });
  121. }
  122. public void CombatUpdate(float time)
  123. {
  124. if (!_isUpdateBasic)
  125. {
  126. return;
  127. }
  128. ProCombatUpdate(time);
  129. if (_timeLineEventParticleLogicBasic == null)
  130. {
  131. return;
  132. }
  133. // Detection();
  134. UnityRenderUpdate(time);
  135. }
  136. public void UnityRenderUpdate(float time)
  137. {
  138. ProUnityRenderUpdate(time);
  139. }
  140. public void Dispose()
  141. {
  142. if (_timeLineEventParticleLogicBasic == null)
  143. {
  144. return;
  145. }
  146. GObjectPool.Instance.Recycle(ObjectPoolInterface);
  147. CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveFxAILogicBasic(this);
  148. ProDispose();
  149. // timeLineEventParticleLogicBasic?.Dispose();
  150. ObjectPoolInterface = null;
  151. _timeLineEventParticleLogicBasic = null;
  152. _attTarget = null;
  153. ObjectPoolInterface = null;
  154. // _fxAiDataBasic = null;
  155. _isUpdateBasic = false;
  156. // UnityRenderUpdateComponent.Instance.RemoveICombatUpdate(this);
  157. // CombatFactoryTool.Instance.Recycle(scName, this);
  158. }
  159. protected virtual void ProInit()
  160. {
  161. }
  162. protected virtual void ProCombatUpdate(float time)
  163. {
  164. }
  165. protected virtual void ProUnityRenderUpdate(float time)
  166. {
  167. }
  168. protected virtual void ProDispose()
  169. {
  170. }
  171. }
  172. }