FxAILogicBasic.cs 6.5 KB

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