FxAILogicBasic.cs 6.5 KB

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