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. _isUpdateBasic = true;
  83. ProInit();
  84. }
  85. public void SetAIMonoObj(IGObjectPoolInterface poolInterface)
  86. {
  87. this.ObjectPoolInterface = poolInterface;
  88. }
  89. // private void Detection()
  90. // {
  91. // if (_updateCount % 2 != 0)
  92. // {
  93. // return;
  94. // }
  95. //
  96. // ProDetection();
  97. // }
  98. //
  99. // protected virtual void ProDetection()
  100. // {
  101. // }
  102. protected void Hit(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
  103. SpecialDotInfo targetSpecialDotInfo)
  104. {
  105. if (string.IsNullOrEmpty(fxName))
  106. {
  107. return;
  108. }
  109. TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(fxName, startPos, fxTarget,
  110. isRotate,
  111. targetSpecialDotInfo, delegate(ParticleSystemPool pool)
  112. {
  113. #if !COMBAT_SERVER
  114. // if (ObjectPoolInterface != null&&pool.own!=null)
  115. // {
  116. // FxColorAlter colorAlter = ObjectPoolInterface.own.GetComponent<FxColorAlter>();
  117. // if (colorAlter != null)
  118. // {
  119. // FxColorAlter colorAlter2 = pool.own.GetComponent<FxColorAlter>();
  120. // if (colorAlter2 == null)
  121. // {
  122. // colorAlter2 = pool.own.AddComponent<FxColorAlter>();
  123. // }
  124. //
  125. // colorAlter2.AlterColor(colorAlter.currValue);
  126. // }
  127. // }
  128. #endif
  129. });
  130. }
  131. public void CombatUpdate(float time)
  132. {
  133. if (!_isUpdateBasic)
  134. {
  135. return;
  136. }
  137. ProCombatUpdate(time);
  138. if (_timeLineEventParticleLogicBasic == null)
  139. {
  140. return;
  141. }
  142. // Detection();
  143. UnityRenderUpdate(time);
  144. }
  145. public void UnityRenderUpdate(float time)
  146. {
  147. ProUnityRenderUpdate(time);
  148. }
  149. public void Dispose()
  150. {
  151. if (_timeLineEventParticleLogicBasic == null)
  152. {
  153. return;
  154. }
  155. GObjectPool.Instance.Recycle(ObjectPoolInterface);
  156. CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveFxAILogicBasic(this);
  157. ProDispose();
  158. // timeLineEventParticleLogicBasic?.Dispose();
  159. ObjectPoolInterface = null;
  160. _timeLineEventParticleLogicBasic = null;
  161. _attTarget = null;
  162. ObjectPoolInterface = null;
  163. // _fxAiDataBasic = null;
  164. _isUpdateBasic = false;
  165. // UnityRenderUpdateComponent.Instance.RemoveICombatUpdate(this);
  166. // CombatFactoryTool.Instance.Recycle(scName, this);
  167. }
  168. protected virtual void ProInit()
  169. {
  170. }
  171. protected virtual void ProCombatUpdate(float time)
  172. {
  173. }
  174. protected virtual void ProUnityRenderUpdate(float time)
  175. {
  176. }
  177. protected virtual void ProDispose()
  178. {
  179. }
  180. }
  181. }