using UnityEngine;
using UnityEngine.AI;

namespace GameLogic.Combat.Hero.State
{
    public class CombatHeroMoveState : CombatHeroStateBasic
    {
        protected Vector3 t;
        public CombatHeroMoveState(CombatHeroEntity combatHeroEntity) : base(combatHeroEntity)
        {
        }

        protected override void ProEnter()
        {
            combatHeroEntity.combatHeroAnimtion.Play("run");
            // SetNewPath();
        }

        protected void SetNewPath()
        {
            Vector3 p = new Vector3(Random.Range(-10, 10), 0, Random.Range(-10, 10));
            t = p;
            combatHeroEntity.CombatAIBasic.NavMeshAgent.SetDestination(p);
            
        }

        protected override void ProUpdate(float t)
        {
            // combatHeroEntity.CombatAIBasic.NavMeshAgent.path.status == NavMeshPathStatus.PathComplete
            // if (Vector3.Distance( combatHeroEntity.CombatAIBasic.NavMeshAgent.pathEndPosition, combatHeroEntity.combatHeroGameObject.position)<0.1)
            // {
            //     SetNewPath();
            // }
            //测试
        }
    }
}