Exemplo n.º 1
0
    // upon trigger entry: //
    private void OnTriggerEnter(Collider collider)
    {
        // code for: gravitizing rigidbodies, player zonage toggling //

        // track any potential rigidbody (local or parent) of the given collider for being gravitized – if it has not been tracked yet //
        Transform rigidbodyTransform = collider.selfOrAncestorTransformWith <Rigidbody>(); // find the transform of this collider's rigidbody, if it has one locally or as a parent; otherwise, determine no transform (null) for this collider's rigidbody transform

        if (rigidbodyTransform)                                                            // if this collider does have a rigidbody (by checking the determined rigidbody transform)
        {
            // determine the rigidbody of this collider (based on the determined rigidbody transform) //
            Rigidbody rigidbodyOfCollider = rigidbodyTransform.GetComponent <Rigidbody>();

            // if: this rigidbody is set to use gravity, this rigidbody has not yet been tracked as one of the rigidbodies to gravitize: //
            if (rigidbodyOfCollider.useGravity && !rigidbodiesToGravitize.Contains(rigidbodyOfCollider))
            {
                // track this collider's rigidbody as one of the rigidbodies to gravitize //
                rigidbodiesToGravitize.Add(rigidbodyOfCollider);

                // if this collider belongs to the player: //
                if (collider.GetComponentInParent <Player>())
                {
                    // toggle the player zonage according to this zone's entry toggling //
                    toggleZonageForPlayerEntry();

                    // if Terrain Response's liftoff audio is set to play upon player entry into this gravity zone: //
                    if (playLiftoffAudioUponPlayerEntry && (gravitizingEnabled || !audioRequiresGravitizing))
                    {
                        // have Terrain Response play random liftoff audio //
                        TerrainResponse.playRandomLiftoffAudio();
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    // methods //


    // method: play audio for player exiting from the all of the Gravity Zones if applicable (and update tracking for the time of last playing accordingly) //
    private static void applicablyPlayAudioForExitFromTheAll()
    {
        if (singleton.playLiftoffAudioUponAllExit && (((Time.time - lastTimeWithinNonzerolyAffectingGravityZonage) <= 1f) || !singleton.audioRequiresAffectation))
        {
            if ((Time.time - timeOfLastLiftoffAudioPlaying) >= TerrainResponse.singleton.liftoffAudioSet.longestLength())
            {
                TerrainResponse.playRandomLiftoffAudio();

                timeOfLastLiftoffAudioPlaying = Time.time;
            }
        }
    }