| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | using UnityEngine;using UnityEngine.AI;namespace GameLogic.Combat.Hero.SubStatus{    public class RepelledStatusState : SubStatusBasic    {        private float repelledDis;        private float speed;        private System.Action callBack;        private float _currMoveDis;        private Vector3 dir;        public RepelledStatusState(Vector3 dir, float repelledDis, float speed, System.Action callBack)        {            this.repelledDis = repelledDis;            this.speed = speed;            this.callBack = callBack;            this.dir = dir.normalized;            _currMoveDis = 0;        }        public override string IsGetStateName()        {            return CombatHeroStateType.NullState;        }        protected override void ProDispose()        {            CombatHeroEntity.CombatAIBasic.stateControl.ChangeState(CombatHeroStateType.idle);        }        protected override void ProUpdate(float t)        {            float addDis = speed * t;            Vector3 pos= CombatHeroEntity.combatHeroGameObject.transform.position + dir * addDis;            CombatHeroEntity.CombatAIBasic.NavMeshAgent.Raycast(pos,                out NavMeshHit hit);            if (!hit.hit)            {                CombatHeroEntity.combatHeroGameObject.transform.position = pos;            }            else            {                callBack?.Invoke();                Dispose();                return;            }            _currMoveDis += addDis;            if (_currMoveDis >= repelledDis)            {                callBack?.Invoke();                Dispose();            }        }    }}
 |