Beispiel #1
0
    AudioPlay currentAudioPlay;                         // Current AudioPlay

    public void Start()
    {
        currentAudioPlay = FindObjectOfType <AudioPlay> ();                     // Gets the current AudioPlay

        bool nothingsPlaying = true;                                            // Nothing is playing intially, so nothingsPlaying is true.


        currentAudio = currentAudioPlay.getAudio();                             // Gets the current AudioSource from the current AudioPlay

        if (levelToLoad == "Level1")                                            // When in the mainMenu... (where the next scene is level 1)
        {
            if (currentAudio.isPlaying)                                         // If the audio is playing, set nothingsPlaying to false.
            {
                nothingsPlaying = false;
            }
            if (currentAudio.clip.name != "L1 Theme")                                   // If the audio playing isn't the level 1 theme, play the level 1 theme.
            {
                currentAudio.clip = currentAudioPlay.level1;
                currentAudio.Play();
            }
            if (nothingsPlaying)                                                                        // If no audio is playing, play the audio
            {
                currentAudio.Play();
            }
        }
    }
Beispiel #2
0
    AudioSource currentAudio;                                   // The current audio souce. Used the change the current clip.

    // Use this for initialization
    void Start()
    {
        playerInZone = false;                                           // player begins out of trigger-zone


        currentAudioPlay = FindObjectOfType <AudioPlay> ();             // Find the instance of AudioPlay to use later.

        // Plays the level 1 music when switching from the win screen to the main menu. This is to allow the music to be in a loop.
        if (levelToLoad == "Level1")
        {
            currentAudio = currentAudioPlay.getAudio();
            if (currentAudio.clip.name == "Won")
            {
                currentAudio.clip = currentAudioPlay.level1;
                currentAudio.Play();
            }
        }
        // Plays the level 2 music when switching from level 1 to level 2.
        else if (levelToLoad == "Level 2")
        {
            currentAudio = currentAudioPlay.audio;
            if (currentAudio.clip.name == "L1 Theme")
            {
                currentAudio.clip = currentAudioPlay.level2;
                currentAudio.Play();
            }
        }
        // Plays the level 3 music when switching from level 2 to level 3.
        else if (levelToLoad == "Level3")
        {
            currentAudio = currentAudioPlay.audio;
            if (currentAudio.clip.name == "ThemeMusicL2" && currentAudio.isPlaying)
            {
                currentAudio.clip = currentAudioPlay.level3;
                currentAudio.Play();
            }
        }
        // Loads the win music when switching from level 3 to the win screen.
        else if (levelToLoad == "MainMenu")
        {
            currentAudio = currentAudioPlay.audio;
            if ((currentAudio.clip.name == "ThemeMusicL3" || currentAudio.clip.name == "L3 Boss") && currentAudio.isPlaying)
            {
                currentAudio.clip = currentAudioPlay.win;
                currentAudio.Play();
            }
            else if (currentAudio.clip.name == "L1 Theme" && !currentAudio.isPlaying)
            {
                currentAudio.clip = currentAudioPlay.win;
                currentAudio.Play();
            }
        }
    }
Beispiel #3
0
    //public float waitBetweenLevels;  // time waiting at between levels scene

    // Use this for initialization
    void Start()
    {
        playerInZone = false;           // player begins out of trigger-zone
        //AudioBegin = PlayerPrefs.GetInt("AudioBegin", 0);


        currentAudioPlay = FindObjectOfType <AudioPlay> ();

        /*nextLevels = FindObjectsOfType<AudioPlay> ();
         *
         * for (var i = 0; i < nextLevels.Length; i++) {
         *      audioList.Add (nextLevels [i]);
         * }
         *
         * Debug.Log ("The next level is: " + levelToLoad);
         * for (var i = 0; i < audioList.Count; i++) {
         *      try {
         *              Debug.Log (i + " " + audioList [i] + " name of clip: " + audioList [i].audio.clip.name + " is playing: " + audioList [i].audio.isPlaying);
         *      }
         *      catch {
         *      }
         * }*/

        if (levelToLoad == "Level1")
        {
            currentAudio = currentAudioPlay.getAudio();
//			Debug.Log (currentAudio.name + " " + currentAudio.clip.name + " " + currentAudio.isPlaying);
            if (currentAudio.clip.name == "Won")
            {
//				Debug.Log ("The current audio is: " + currentAudio.clip.name);
                currentAudio.clip = currentAudioPlay.level1;
                currentAudio.Play();
            }
        }
        else if (levelToLoad == "Level 2")
        {
            currentAudio = currentAudioPlay.audio;
            if (currentAudio.clip.name == "L1 Theme")
            {
//				Debug.Log ("The current audio is: " + currentAudio.clip.name);
                currentAudio.clip = currentAudioPlay.level2;
                currentAudio.Play();
            }
        }
        else if (levelToLoad == "Level3")
        {
            currentAudio = currentAudioPlay.audio;
            if (currentAudio.clip.name == "ThemeMusicL2" && currentAudio.isPlaying)
            {
//				Debug.Log ("The current audio is: " + currentAudio.clip.name);
                currentAudio.clip = currentAudioPlay.level3;
                currentAudio.Play();
            }
        }
        else if (levelToLoad == "MainMenu")
        {
            currentAudio = currentAudioPlay.audio;
//			Debug.Log (currentAudio.clip.name + " " + currentAudio.isPlaying);
//			Debug.Log ("Current audio name" + currentAudio.clip.name + " is it playing? " + currentAudio.isPlaying);
            if ((currentAudio.clip.name == "ThemeMusicL3" || currentAudio.clip.name == "L3 Boss") && currentAudio.isPlaying)
            {
//				Debug.Log ("The current audio is: " + currentAudio.clip.name);
                currentAudio.clip = currentAudioPlay.win;
                currentAudio.Play();
            }
            else if (currentAudio.clip.name == "L1 Theme" && !currentAudio.isPlaying)
            {
                currentAudio.clip = currentAudioPlay.win;
                currentAudio.Play();
            }
        }
    }