예제 #1
0
    void Update()
    {
        if (stateController.IsCurrentStateInRange(State.Appear, State.Disappear))
        {
            return;
        }
        if (isGrounded || isGuidedJump)
        {
            float moveDirection = Input.GetAxis("Horizontal");
            playerBody.velocity = new Vector2(moveDirection * runSpeed, playerBody.velocity.y);
            if (moveDirection == 0)
            {
                stateController.SetState(State.Idle);
            }
            else if (isGrounded)
            {
                stateController.SetState(State.Run);
            }
            if ((moveDirection > 0 && !isFacingRight) || (moveDirection < 0 && isFacingRight))
            {
                Flip();
            }
        }

        if (Controls.IsJumpKeyDown && isJumpAvailable)
        {
            StartCoroutine(JumpRoute());
        }
        else if (Controls.IsJumpKeyUp)
        {
            StopCoroutine(JumpRoute());
        }
    }