示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Jump") && !isFalling && !isWaiting)
        {
            Jump();
            isFalling = true;
        }
        float move = Input.GetAxis("Horizontal");

        if (move != 0 && !isWaiting)
        {
            if (move > 0)
            {
                gameObject.transform.localScale = new Vector2(5, 5);
            }
            else if (move < 0)
            {
                gameObject.transform.localScale = new Vector2(-5, 5);
            }
            playerAnimation.AnimationWalk();
            rb2d.velocity = new Vector2(move * maxVelocity, rb2d.velocity.y);
        }
        else
        {
            playerAnimation.StayAnimation();
        }
        if (Input.GetKey(KeyCode.Q))
        {
            if (isSuper)
            {
                playerAnimation.ShootAnimation();
                isWaiting = true;
            }
            else
            {
                playerAnimation.NoChargeAnim();
                if (!letsGo)
                {
                    isWaiting = true;
                    if (!CoRunning)
                    {
                        StartCoroutine(waiter_not_that_waiter_just_waiter(.5f));
                    }
                    return;
                }
            }
        }
        if (Input.GetKeyUp(KeyCode.Q))
        {
            if (isSuper)
            {
                isWaiting = false;
                playerAnimation.StayAnimation();
            }
        }
        if (lives == 0)
        {
            playerAnimation.DieAnimation();
            if (!letsGo)
            {
                isWaiting = true;
                if (!CoRunning)
                {
                    StartCoroutine(dieWaiter(3f));
                }
                return;
            }
        }
    }