Esempio n. 1
0
        /// <summary>
        /// Changes the currently playing menu music to the music assigned to the given (screen) name.
        /// </summary>
        /// <param name="name">The (screen) name to use as the new playing menu music.</param>
        public void ChangeMusic(string name)
        {
            if (name == "SongSelect")
            {
                //The Song Select screen takes over the Crossfader at this point for song previews.
                _currentMusic = "";
                _musicChannel = -1;
                return;
            }

            if (!_musicList.ContainsKey(name))
            {
                StopExistingMusic();
                return;
            }

            if ((!Directory.Exists(MusicFilePath)) || (!File.Exists(MusicFilePath + _musicList[name])))
            {
                Log.AddMessage("MenuMusicManager: Skipping load of '" + name + "' as the file was not found.",
                               LogLevel.WARN);
                Log.AddMessage("Searched in: " + MusicFilePath + _musicList[name], LogLevel.WARN);
                StopExistingMusic();
                return;
            }
            if (_currentMusic == _musicList[name])
            {
                Log.AddMessage("MenuMusicManager: Selected music is already playing. Skipping load.", LogLevel.INFO);
                return;
            }

            _currentMusic = _musicList[name];
            _musicChannel = AudioManager.PlaySoundEffect(MusicFilePath + _musicList[name], true, false);
            Crossfader.PreviewDuration = 0;
            Crossfader.SetNewChannel(_musicChannel);
        }
Esempio n. 2
0
 /// <summary>
 /// Stops the currently playing menu music.
 /// </summary>
 private void StopExistingMusic()
 {
     _musicChannel = -1;
     _currentMusic = "";
     if (Crossfader.ChannelIndexCurrent != -1)
     {
         Crossfader.SetNewChannel(_musicChannel);
     }
 }
Esempio n. 3
0
 void Awake()
 {
     transition = GetComponent <Animator>();
     current    = this;
 }