FxAILogicBasic.cs 6.0 KB

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