FxAILogicBasic.cs 7.9 KB

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