Esempio n. 1
0
    /// <summary>
    /// This Method Accesses the playercontroller, and then switches the player color from the playercontroller, next it accesses the
    /// ColliderController and Runs the ChangeColliderState Mehtod.  Next it plays the colorchange pickup sound and then disables the
    /// color change pickup object so that it goes back into the pool, and can be used again.
    /// </summary>
    public void ChangePlayerColor()
    {
        //switch color from the playercontroller
        pController.SwitchPlayerColor();
        //Change color collider state from the ColliderController
        cColliderController.ChangeColorColliderState();
        //Increments the "Obstacle Progression" which spawns more obstacles about 2 obstacle lengths above the player
        cColliderController.IncrementObstacleProgression();

        //if there is a sound clip for picking up a color change object... then play it.
        if (colorChangeSound)
        {
            AudioSource.PlayClipAtPoint(colorChangeSound, transform.position, localSoundVolume * 2f);

            //THIS IS OLD CODE--  I used to get the first two obstacles on screen by leaving
            //2 pickup items right on top of the player start position.  So this if/else below
            //prevented that sound from playing before the player actually got moving

            //if (TemporaryGameVars.playerScore == 0)
            //{
            //    Debug.Log("Supressing Score Change Sound");
            //}
            //else
            //{
            //    AudioSource.PlayClipAtPoint(colorChangeSound, transform.position, localSoundVolume * 2f);
            //}
        }

        //instantiate this effect
        //Instantiate(effectToInstantiate, transform.position, transform.rotation);

        //disable the object so that it appears "destroyed" or "PickedUp", and then it will be available in the pool again.
        this.gameObject.SetActive(false);
    }
    public void ChangePlayerColor()
    {
        pController.SwitchPlayerColor();
        cColliderController.ChangeColorColliderState();
        cColliderController.IncrementObstacleProgression();

        if (colorChangeSound)
        {
            AudioSource.PlayClipAtPoint(colorChangeSound, transform.position, localSoundVolume * 2f);
        }

        this.gameObject.SetActive(false);
    }