// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        AIFleetController controller = animator.GetComponent <AIFleetController>();

        if (controller.CurrentWaypoint == null)
        {
            controller.CurrentWaypoint = WaypointManager.Instance.GetRandomWaypoint();
        }
    }
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        AIFleetController controller = animator.GetComponent <AIFleetController>();

        controller.UpdateWaypoint();
        if (controller.DetectTarget())
        {
            animator.Play("Chase");
        }
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    // override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    // {

    // }

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        AIFleetController controller = animator.GetComponent <AIFleetController>();

        if (controller.ValidateTarget() == false)
        {
            animator.Play("Patrol");
        }
        else if (controller.IsInAttackRange())
        {
            animator.Play("Attack");
        }
        else
        {
            controller.ChaseTarget();
        }
    }
Esempio n. 4
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        AIFleetController controller = animator.GetComponent <AIFleetController>();

        if (controller.ValidateTarget() == false)
        {
            animator.Play("Patrol");
        }
        else if (!controller.IsInAttackRange())
        {
            animator.Play("Chase");
        }
        else
        {
            controller.ChaseTarget();
            FireSide fireSide = controller.ShouldFire();
            if (fireSide != FireSide.NONE)
            {
                controller.Fire(fireSide);
                animator.Play("Chase");
            }
        }
    }