예제 #1
0
    private void HandleGravity()
    {
        if (cc.Bottom() || cc.Left() || cc.Right())
        {
            numberOfJumps = 1;
        }

        if (Jump() && numberOfJumps != 0)
        {
            numberOfJumps--;
            vel.y = 21.5f;
            if (cc.Left() || cc.Right())
            {
                hadJumpedOffWall = true;
                if (cc.Left())
                {
                    vel.x = 15f;
                }
                if (cc.Right())
                {
                    vel.x = -15f;
                }
            }
        }

        if (Input.GetKey(KeyCode.C) && vel.y > 0.0f)
        {
            vel.y -= 32f * Time.fixedDeltaTime;
        }
        else if (vel.y > 0.0f)
        {
            vel.y -= 50f * Time.fixedDeltaTime;
        }

        if (vel.y <= 0.0f)
        {
            vel.y -= 47f * Time.fixedDeltaTime;
        }

        if ((cc.Left() || cc.Right()) && vel.y < 0.0f)
        {
            vel.y *= 0.99f;
        }

        if (vel.y <= -21.5f && Input.GetKey(KeyCode.C))
        {
            vel.y = -21.5f;
        }
        else if (vel.y <= -24f)
        {
            vel.y = -24f;
        }

        if (vel.y <= 0.0f && cc.Bottom())
        {
            vel.y = 0.0f;
        }
    }