예제 #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();
        }
    }
    // updating //


    // at each update: //
    public override void update()
    {
        // if the number of midair jumps provided is -1 (standing for infinity): set the midair jumps count to -1 (standing for infinity)
        if (midairJumpsProvided == -1)
        {
            midairJumpsCount = -1;
        }
        // if the player is terrained: //
        if (TerrainResponse.terrained())
        {
            // if the midair jumps count is lower than the number of jumps provided: raise the midair jumps count to the number of jumps provided //
            if (midairJumpsCount < midairJumpsProvided)
            {
                midairJumpsCount = midairJumpsProvided;
            }
        }
    }
 // at each update: playing emission accordingly //
 private void Update()
 {
     // if the booster is boosting as necessary: //
     if (dependencies.areMet())
     {
         // if the player is grounded or the smoke ring is allowed to play when nongrounded and the player is terrained: track that the player was terrained at the last update //
         if (TerrainResponse.grounded() || (smokeRingWhenNongrounded && TerrainResponse.terrained()))
         {
             appropriatelyTerrainedAtLastUpdate = true;
         }
         // otherwise: if the player was terrained at the last update: track that the player was not terrained at the last update, play one round of emission of the booster smoke ring emitter //
         else if (appropriatelyTerrainedAtLastUpdate)
         {
             appropriatelyTerrainedAtLastUpdate = false;
             emitter.Play();
         }
     }
 }
예제 #4
0
    // methods //


    // method: determine the (boolean) state of this Dependency Requisite //
    public override bool state()
    {
        return(TerrainResponse.terrained());
    }