示例#1
0
    private void playerActions(string clipName)
    {
        if (Input.GetKey("right"))
        {
            run("right");
            runAnimation();
        }
        else if (Input.GetKey("left"))
        {
            run("left");
            runAnimation();
        }

        if (Input.GetKey("down"))
        {
            crunchAnimation();
        }
        else if (Input.GetKeyUp("down"))
        {
            //postCrunchAnimation();
            animator.SetBool("IsCrunched", false);
        }
        else
        {
            idleAnimation(clipName);
        }

        if (Input.GetKeyDown("up") && grounded && energyController.HasEnergyForAction(PlayerAction.Jump))
        {
            rgdb.velocity = new Vector2(velocityX, jumpTakeOffSpeed);
            if (playerAction == PlayerAction.Crunch)
            {
                playerAction  = PlayerAction.JumpHigher;
                rgdb.velocity = new Vector2(velocityX, jumpTakeOffSpeed * 1.2f);
            }
            playerAction = PlayerAction.Jump;
        }
        else if (Input.GetKeyUp("up"))
        {
            if (velocityY > 0)
            {
                rgdb.velocity = new Vector2(velocityX, rgdb.velocity.y * 0.5f);
            }
        }

        jumpAnimation(clipName);
    }