FxAILogicBasic.cs 7.6 KB

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