FxAILogicBasic.cs 8.4 KB

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