using System; using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic; using Fort23.Common; using Fort23.Core; using Fort23.UTool; using GameLogic.Combat.CombatTool; #if !COMBAT_SERVER using UnityEngine; #endif using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface; using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic; namespace Common.Combat.FxAILogic { public abstract class FxAILogicBasic : MonoBehaviour, IDisposable, ITimelineFxLogic { private TimeLineEventParticleLogicBasic _timeLineEventParticleLogicBasic; private ILifetCycleHitPoint _attTarget; [Header("碰撞时的特效")] public string hitFxName; [Header("碰撞音效")] public string hitAudioName; public ILifetCycleHitPoint AttTarget { get { return _attTarget; } } public CombatHeroEntity CombatHeroEntity { get { return _combatHeroEntity; } } private CombatHeroEntity _combatHeroEntity; public TimeLineEventParticleLogicBasic TimeLineEventParticleLogicBasic { get { return _timeLineEventParticleLogicBasic; } } public IGObjectPoolInterface ObjectPoolInterface; public bool isPenetrate; [Header("是否使用自定义目标结束点")] public bool isUseCustomTargetEndPos; [Header("结束点的下标")] public int customTargetEndPosIndex; /// /// 开始点 /// protected Vector3 startPos; public Vector3 CurrPos { get { return _currPos; } } /// /// 当前Obj的位置 /// protected Vector3 _currPos; protected Vector3 rotation; protected SpecialDotInfo specialDotInfo; protected float currTime; public TriggerData triggerData; protected bool isNotCanTriggerGround; protected bool _isUpdateBasic; public void Init(Vector3 startPos, TimeLineEventParticleLogicBasic timeLineEventParticleLogicBasic, ILifetCycleHitPoint attTarget, SpecialDotInfo specialDotInfo = null) { if (timeLineEventParticleLogicBasic.castEntity == null) { Dispose(); return; } _currPos = startPos; this.startPos = startPos; this._timeLineEventParticleLogicBasic = timeLineEventParticleLogicBasic; this._attTarget = attTarget; _combatHeroEntity = timeLineEventParticleLogicBasic.castEntity.This(); this.specialDotInfo = specialDotInfo; ITimeLineTriggerEvent trigger = timeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent; if (trigger != null) { trigger.TimelineFxLogicInit(timeLineEventParticleLogicBasic.timeLinePlayFxSerializtion.groupName, this, triggerData); } triggerData = timeLineEventParticleLogicBasic.extraData; triggerData.TrggerObject = this; _isUpdateBasic = true; ProInit(); } public void SetAIMonoObj(IGObjectPoolInterface poolInterface) { this.ObjectPoolInterface = poolInterface; } // private void Detection() // { // if (_updateCount % 2 != 0) // { // return; // } // // ProDetection(); // } // // protected virtual void ProDetection() // { // } protected void Hit(string fxName, Vector3 startPos, ILifetCycleHitPoint fxTarget, bool isRotate, SpecialDotInfo targetSpecialDotInfo) { if (string.IsNullOrEmpty(fxName)) { return; } TimeLineFxParticleTool.Instance.TimeLineFxParticleFactory.CreateParticle(fxName, startPos, fxTarget, isRotate, targetSpecialDotInfo, delegate(ParticleSystemPool pool) { #if !COMBAT_SERVER // if (ObjectPoolInterface != null&&pool.own!=null) // { // FxColorAlter colorAlter = ObjectPoolInterface.own.GetComponent(); // if (colorAlter != null) // { // FxColorAlter colorAlter2 = pool.own.GetComponent(); // if (colorAlter2 == null) // { // colorAlter2 = pool.own.AddComponent(); // } // // colorAlter2.AlterColor(colorAlter.currValue); // } // } #endif }); } public void CombatUpdate(float time) { if (!_isUpdateBasic) { return; } ProCombatUpdate(time); if (_timeLineEventParticleLogicBasic == null) { return; } // Detection(); UnityRenderUpdate(time); } public void UnityRenderUpdate(float time) { ProUnityRenderUpdate(time); } public void Dispose() { if (_timeLineEventParticleLogicBasic == null) { return; } GObjectPool.Instance.Recycle(ObjectPoolInterface); CombatController.currActiveCombat.GameTimeLineParticleFactory.RemoveFxAILogicBasic(this); ProDispose(); // timeLineEventParticleLogicBasic?.Dispose(); ObjectPoolInterface = null; _timeLineEventParticleLogicBasic = null; _attTarget = null; ObjectPoolInterface = null; // _fxAiDataBasic = null; _isUpdateBasic = false; // UnityRenderUpdateComponent.Instance.RemoveICombatUpdate(this); // CombatFactoryTool.Instance.Recycle(scName, this); } protected virtual void ProInit() { } protected virtual void ProCombatUpdate(float time) { } protected virtual void ProUnityRenderUpdate(float time) { } protected virtual void ProDispose() { } } }