FxAILogicBasic.cs 8.1 KB

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