FxAILogicBasic.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 string hitFxName;
  23. [Header("碰撞音效")] 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. private float _currDelayTime;
  60. public void Init(Vector3 startPos,
  61. TimeLineEventParticleLogicBasic timeLineEventParticleLogicBasic, ILifetCycleHitPoint attTarget,
  62. SpecialDotInfo specialDotInfo = null)
  63. {
  64. if (timeLineEventParticleLogicBasic.castEntity == null)
  65. {
  66. Dispose();
  67. return;
  68. }
  69. _currDelayTime = 0;
  70. _currPos = startPos;
  71. this.startPos = startPos;
  72. this._timeLineEventParticleLogicBasic = timeLineEventParticleLogicBasic;
  73. this._attTarget = attTarget;
  74. _combatHeroEntity = timeLineEventParticleLogicBasic.castEntity.This<CombatHeroEntity>();
  75. this.specialDotInfo = specialDotInfo;
  76. ITimeLineTriggerEvent trigger =
  77. timeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
  78. if (trigger != null)
  79. {
  80. trigger.TimelineFxLogicInit(timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.groupName, this,
  81. triggerData);
  82. SkillBasic skillBasic = trigger as SkillBasic;
  83. SkillFeaturesData = skillBasic.GetSkillFeaturesData();
  84. }
  85. triggerData = timeLineEventParticleLogicBasic.extraData;
  86. triggerData.TrggerObject = this;
  87. currTime = 0;
  88. _isUpdateBasic = true;
  89. ProInit();
  90. }
  91. public void SetAIMonoObj(IGObjectPoolInterface poolInterface)
  92. {
  93. this.ObjectPoolInterface = poolInterface;
  94. }
  95. // private void Detection()
  96. // {
  97. // if (_updateCount % 2 != 0)
  98. // {
  99. // return;
  100. // }
  101. //
  102. // ProDetection();
  103. // }
  104. //
  105. // protected virtual void ProDetection()
  106. // {
  107. // }
  108. public void PlayHit()
  109. {
  110. FinishHit(CurrPos,hitFxName);
  111. }
  112. protected void FinishHit(Vector3 pos, string hitFxName)
  113. {
  114. if (!string.IsNullOrEmpty(hitFxName))
  115. {
  116. CombatController.currActiveCombat.GameTimeLineParticleFactory.CreateParticle(hitFxName,
  117. pos, null, false, null, null);
  118. }
  119. }
  120. protected void Hit(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
  121. SpecialDotInfo targetSpecialDotInfo)
  122. {
  123. if (string.IsNullOrEmpty(fxName))
  124. {
  125. return;
  126. }
  127. TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(fxName, startPos, fxTarget,
  128. isRotate,
  129. targetSpecialDotInfo, delegate(ParticleSystemPool pool)
  130. {
  131. #if !COMBAT_SERVER
  132. // if (ObjectPoolInterface != null&&pool.own!=null)
  133. // {
  134. // FxColorAlter colorAlter = ObjectPoolInterface.own.GetComponent<FxColorAlter>();
  135. // if (colorAlter != null)
  136. // {
  137. // FxColorAlter colorAlter2 = pool.own.GetComponent<FxColorAlter>();
  138. // if (colorAlter2 == null)
  139. // {
  140. // colorAlter2 = pool.own.AddComponent<FxColorAlter>();
  141. // }
  142. //
  143. // colorAlter2.AlterColor(colorAlter.currValue);
  144. // }
  145. // }
  146. #endif
  147. });
  148. }
  149. public void CombatUpdate(float time)
  150. {
  151. if (!_isUpdateBasic)
  152. {
  153. return;
  154. }
  155. _currDelayTime+=time;
  156. if (_currDelayTime < delayTime)
  157. {
  158. return;
  159. }
  160. ProCombatUpdate(time);
  161. if (_timeLineEventParticleLogicBasic == null)
  162. {
  163. return;
  164. }
  165. // Detection();
  166. UnityRenderUpdate(time);
  167. }
  168. public void UnityRenderUpdate(float time)
  169. {
  170. ProUnityRenderUpdate(time);
  171. }
  172. public void Dispose()
  173. {
  174. if (_timeLineEventParticleLogicBasic == null)
  175. {
  176. return;
  177. }
  178. GObjectPool.Instance.Recycle(ObjectPoolInterface);
  179. CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveFxAILogicBasic(this);
  180. ProDispose();
  181. // timeLineEventParticleLogicBasic?.Dispose();
  182. ObjectPoolInterface = null;
  183. _timeLineEventParticleLogicBasic = null;
  184. _attTarget = null;
  185. ObjectPoolInterface = null;
  186. // _fxAiDataBasic = null;
  187. _isUpdateBasic = false;
  188. // UnityRenderUpdateComponent.Instance.RemoveICombatUpdate(this);
  189. // CombatFactoryTool.Instance.Recycle(scName, this);
  190. }
  191. protected virtual void ProInit()
  192. {
  193. }
  194. protected virtual void ProCombatUpdate(float time)
  195. {
  196. }
  197. protected virtual void ProUnityRenderUpdate(float time)
  198. {
  199. }
  200. protected virtual void ProDispose()
  201. {
  202. }
  203. }
  204. }