FxAILogicBasic.cs 8.2 KB

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