FxAILogicBasic.cs 9.4 KB

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