FxAILogicBasic.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. [Header("是否可以穿透")] 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. /// <summary>
  125. /// 扣除技能强度
  126. /// </summary>
  127. public void DeductSkillStrength(long hp)
  128. {
  129. }
  130. // private void Detection()
  131. // {
  132. // if (_updateCount % 2 != 0)
  133. // {
  134. // return;
  135. // }
  136. //
  137. // ProDetection();
  138. // }
  139. //
  140. // protected virtual void ProDetection()
  141. // {
  142. // }
  143. public void PlayHit()
  144. {
  145. FinishHit(CurrPos, hitFxName);
  146. }
  147. protected void FinishHit(Vector3 pos, string hitFxName)
  148. {
  149. if (!string.IsNullOrEmpty(hitFxName))
  150. {
  151. CombatController.currActiveCombat.GameTimeLineParticleFactory.CreateParticle(hitFxName,
  152. pos, null, false, null, null);
  153. }
  154. }
  155. protected void Hit(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate,
  156. SpecialDotInfo targetSpecialDotInfo)
  157. {
  158. if (string.IsNullOrEmpty(fxName))
  159. {
  160. return;
  161. }
  162. TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(fxName, startPos, fxTarget,
  163. isRotate,
  164. targetSpecialDotInfo, delegate(ParticleSystemPool pool)
  165. {
  166. #if !COMBAT_SERVER
  167. // if (ObjectPoolInterface != null&&pool.own!=null)
  168. // {
  169. // FxColorAlter colorAlter = ObjectPoolInterface.own.GetComponent<FxColorAlter>();
  170. // if (colorAlter != null)
  171. // {
  172. // FxColorAlter colorAlter2 = pool.own.GetComponent<FxColorAlter>();
  173. // if (colorAlter2 == null)
  174. // {
  175. // colorAlter2 = pool.own.AddComponent<FxColorAlter>();
  176. // }
  177. //
  178. // colorAlter2.AlterColor(colorAlter.currValue);
  179. // }
  180. // }
  181. #endif
  182. });
  183. }
  184. public virtual void CombatUpdate(float time)
  185. {
  186. if (!_isUpdateBasic)
  187. {
  188. return;
  189. }
  190. _currDelayTime += time;
  191. if (_currDelayTime < _currAllDelayTime)
  192. {
  193. return;
  194. }
  195. ProCombatUpdate(time);
  196. if (_timeLineEventParticleLogicBasic == null)
  197. {
  198. return;
  199. }
  200. // Detection();
  201. UnityRenderUpdate(time);
  202. }
  203. public void UnityRenderUpdate(float time)
  204. {
  205. ProUnityRenderUpdate(time);
  206. }
  207. public void Dispose()
  208. {
  209. if (_timeLineEventParticleLogicBasic == null)
  210. {
  211. return;
  212. }
  213. isInit = false;
  214. isNotMove = false;
  215. GObjectPool.Instance.Recycle(ObjectPoolInterface);
  216. CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveFxAILogicBasic(this);
  217. ProDispose();
  218. // timeLineEventParticleLogicBasic?.Dispose();
  219. ObjectPoolInterface = null;
  220. _timeLineEventParticleLogicBasic = null;
  221. _attTarget = null;
  222. ObjectPoolInterface = null;
  223. // _fxAiDataBasic = null;
  224. _isUpdateBasic = false;
  225. // UnityRenderUpdateComponent.Instance.RemoveICombatUpdate(this);
  226. // CombatFactoryTool.Instance.Recycle(scName, this);
  227. }
  228. protected virtual void ProInit()
  229. {
  230. }
  231. protected virtual void ProCombatUpdate(float time)
  232. {
  233. }
  234. protected virtual void ProUnityRenderUpdate(float time)
  235. {
  236. }
  237. protected virtual void ProDispose()
  238. {
  239. }
  240. }
  241. }