Exemple #1
0
    public override TaskStatus OnUpdate()
    {
        ANIMATIONSTATE st = sdself.Value.Status.State;

        if (st == ANIMATIONSTATE.IDLE)
        {
            return(TaskStatus.Success);
        }
        else
        {
            return(TaskStatus.Failure);
        }
    }
Exemple #2
0
    // fall over and attack player
    void deploySequence()
    {
        // find direction to player
        Vector3 direction = (player.transform.position - transform.position).normalized;

        direction.y = 0;

        // snap to look at player
        transform.rotation = Quaternion.Euler(Vector3.up * 90) * Quaternion.LookRotation(direction);

        ANIMATIONSTATE currentAnimationState = (ANIMATIONSTATE)myAnimator.GetInteger("animationState");

        // if the current animation is finished
        switch (currentAnimationState)
        {
        case ANIMATIONSTATE.SHOOT:
            shootPlayer();
            break;
        }

        // switch to the next animation
        if (myAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1 && !myAnimator.IsInTransition(0))
        {
            // run next animation (if the player is within range
            switch (myAnimator.GetInteger("animationState"))
            {
            case (int)ANIMATIONSTATE.GETUP:
                // transition back to rolling
                myAnimator.SetInteger("animationState", 0);
                deployed = false;
                break;

            case (int)ANIMATIONSTATE.SHOOT:
                // keep shooting the player until they are out of range
                if (!nearPlayer())
                {
                    myAnimator.SetInteger("animationState", (int)ANIMATIONSTATE.LOWERGUN);
                    myLineRenderer.enabled = false;
                }
                break;

            default:
                // transition into the next animation
                myAnimator.SetInteger("animationState", myAnimator.GetInteger("animationState") + 1);
                break;
            }
        }
    }