FxAILogicBasic.cs 8.6 KB

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