FxAILogicBasic.cs 6.4 KB

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