Ejemplo n.º 1
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("Attack");
        }
        else
        {
            controller.ChaseTarget();
        }
    }
Ejemplo n.º 2
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");
            }
        }
    }