Ejemplo n.º 1
0
    // Chooses the main loop music based on the player's choice.
    // If the player hasn't chosen any, it will be based on difficulty.
    private IEnumerator ChooseMainLoopMusic()
    {
        bool choosing = true;

        while (choosing)
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                mainLoopMusic = stemPlayers[0];
                choosing      = false;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                mainLoopMusic = stemPlayers[1];
                choosing      = false;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                mainLoopMusic = stemPlayers[2];
                choosing      = false;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha4))
            {
                mainLoopMusic = stemPlayers[3];
                choosing      = false;
            }
            yield return(null);
        }
    }
Ejemplo n.º 2
0
    IEnumerator CrossFade_(StemPlayer stemsIn, AudioSource audioOut, float xfadeTime)
    {
        // Same principle as the former funtions.
        while (isFading)
        {
            yield return(null);
        }
        isFading = true;
        stemsIn.Play(xfadeTime);
        fader.FadeOutAndStop(audioOut, xfadeTime);

        yield return(new WaitForSeconds(xfadeTime));

        isFading = false;
    }
Ejemplo n.º 3
0
    // The MusicController will not be ready until all stemPlayers are ready. Any other future initialization should be put here as well.
    // Any component that wishes to use the music controller should check if it's ready before the first use.
    IEnumerator InitializePlayers_()
    {
        for (int i = 0; i < stemPlayers.Length; i++)
        {
            while (!stemPlayers[i].StemPlayerReady())
            {
                yield return(null);
            }
        }
        musicControllerReady = true;
        mainLoopMusic        = stemPlayers[0];

        mainLoopMusic.Play();

        StartCoroutine(MainLoop_());
    }
Ejemplo n.º 4
0
    IEnumerator CrossFade_(AudioSource audioIn, StemPlayer stemsOut, float xfadeTime)
    {
        // Waits until nothing is fading.
        while (isFading)
        {
            yield return(null);
        }
        isFading = true;
        // Fades out the stem player that is supposed to stop playing.
        stemsOut.Stop(xfadeTime);
        // Fades in the audio source that is supposed to start playing.
        fader.StartAndFadeIn(audioIn, xfadeTime, mainThemeVolume);
        // Waits for the fade.
        yield return(new WaitForSeconds(xfadeTime));

        isFading = false;
    }
Ejemplo n.º 5
0
 // Cross fades a StemPlayer in with as AudioSource out in xfadeTime seconds.
 public void CrossFade(StemPlayer stemsIn, AudioSource audioOut, float xfadeTime)
 {
     CancelInvoke();
     StopAllCoroutines();
     StartCoroutine(CrossFade_(stemsIn, audioOut, xfadeTime));
 }