示例#1
0
    // at each update: //
    private void Update()
    {
        // if: the player is ready to jump, the player is terrained or midair jumping is available, locomotion input is enabled and allowed, locomotion input is pressing, this jumper's priority is not overridden: //
        if (JumpingSettings.jumpingReady() && (TerrainResponse.terrained() || JumpingSettings.midairJumpingAvailable()) && locomotionInputEnabledAndAllowed() && controller.inputPressing(inputsLocomotion) && !priorityOverridden())
        {
            // handle midair jumping //
            if (!TerrainResponse.terrained())
            {
                Vector3 playerVelocity = PlayerVelocityReader.velocity();

                if (midairJumpingReplacesVelocity && ((playerVelocity.y < forceAmount) || (Flipper.flipped && (playerVelocity.y > -forceAmount))))
                {
                    playerRigidbody.velocity = new Vector3(playerVelocity.x, 0f, playerVelocity.z);
                }

                if (!JumpingSettings.midairJumpingInfinite())
                {
                    JumpingSettings.decrementMidairJumpsCount();
                }
            }

            // play the attached jumping audio //
            playJumpingAudio();

            // change the player's velocity for this jumping //
            playerRigidbody.velocity += new Vector3(0f, (Flipper.flipped ? -forceAmount : forceAmount), 0f);

            // have Jumping Settings track the time of the last jump as right now //
            JumpingSettings.trackTimeOfLastJump();
        }
    }
    // methods //


    // method: determine the (boolean) state of this Dependency Requisite //
    public override bool state()
    {
        return(JumpingSettings.lastJumpedWithin(1f));
    }