Beispiel #1
0
 // Start is called before the first frame update
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Beispiel #2
0
 public void Update()
 {
     switch (MediaPlayer.State)
     {
         case (MediaState.Playing):
             State = MusicStates.Playing;
             break;
         case (MediaState.Paused):
             State = MusicStates.Paused;
             break;
         case (MediaState.Stopped):
             State = MusicStates.Stopped;
             break;
     }
 }
Beispiel #3
0
        public void Update()
        {
            switch (MediaPlayer.State)
            {
            case (MediaState.Playing):
                State = MusicStates.Playing;
                break;

            case (MediaState.Paused):
                State = MusicStates.Paused;
                break;

            case (MediaState.Stopped):
                State = MusicStates.Stopped;
                break;
            }
        }
Beispiel #4
0
        void Awake()
        {
            _runtimeAudioSettings = new RuntimeChangableSettings();
            _generalAudioSettings = new GeneralAudioSettings();

            LoadRuntimeChangableAudioSettings();
            LoadAudioConfiguration();

            musicSource = AddAudioSource();
            soundSource = new List <AudioSource>();
            soundSource.Add(AddAudioSource());

            audioBlock        = new AudioBlock();
            delay             = 0;
            _musicTrackVolume = 0;
            _musicState       = MusicStates.Default;
        }
Beispiel #5
0
        ///*
        public void PlayMusic(bool fade = false)
        {
            if (!_runtimeAudioSettings.UseMusic)
            {
                return;
            }

            if (fade && fadeTime > 0)
            {
                _musicState = MusicStates.FadeOut;
                return;
            }

            audioBlock.PlayRandomMusic(musicSource, this.MaxRealMusicVolume);
            _musicTrackVolume = musicSource.volume;
            delay             = audioBlock.music.delay;
        }
Beispiel #6
0
        //public void PlayMusic()
        //{
        //    PlayMusic(_generalAudioSettings.FadeMode, _generalAudioSettings.FadeDuration);
        //}

        /*
         * private void Update()
         * {
         *  switch (_generalAudioSettings.FadeMode)
         *  {
         *      case FadeMods.NotFading:
         *          MusicPlayerDefaultMode();
         *          break;
         *  }
         * }
         */

        private void MusicPlayerDefaultMode()
        {
            if (_musicState == MusicStates.Stop)
            {
                return;
            }

            if (!_runtimeAudioSettings.UseMusic)
            {
                musicSource.Stop();
                _musicState = MusicStates.Stop;
                return;
            }

            if (!musicSource.isPlaying)
            {
                if (_musicState != MusicStates.Wait)
                {
                    delay       = audioBlock.music.delay;
                    _musicState = MusicStates.Wait;
                }
                else
                {
                    delay -= Time.unscaledDeltaTime;
                    if (delay <= 0f)
                    {
                        PlayMusic();
                        _musicState = MusicStates.Default;
                    }
                }
            }
            else
            {
                _musicState = MusicStates.Default;
            }
        }
Beispiel #7
0
 public Music(IDisposableResource parent, string filename)
     : base(parent)
 {
     State = MusicStates.Stopped;
 }
Beispiel #8
0
        void Update()
        {
            if (musicSource.isPlaying)
            {
                if (!_runtimeAudioSettings.UseMusic)
                {
                    if (Fade(false))
                    {
                        musicSource.Stop();
                    }
                }

                if (_musicState == MusicStates.Default)
                {
                    return;
                }
            }

            if (!_runtimeAudioSettings.UseMusic)
            {
                return;
            }

            if (_musicState == MusicStates.FadeOut)
            {
                if (musicSource.isPlaying)
                {
                    if (Fade(false))
                    {
                        if (fadeOn)
                        {
                            nextTrackName     = audioBlock.GetRandomMusic();
                            _musicTrackVolume = this.MaxRealMusicVolume * audioBlock.music.tracks[nextTrackName].Volume;
                            audioBlock.PlayMusic(musicSource, nextTrackName, 0);
                            _musicState = MusicStates.FadeIn;
                            return;
                        }
                        PlayMusic();
                        _musicState = MusicStates.Default;
                        return;
                    }
                }
                else
                {
                    if (fadeOn)
                    {
                        nextTrackName     = audioBlock.GetRandomMusic();
                        _musicTrackVolume = this.MaxRealMusicVolume * audioBlock.music.tracks[nextTrackName].Volume;
                        audioBlock.PlayMusic(musicSource, nextTrackName, 0);
                        _musicState = MusicStates.FadeIn;
                        return;
                    }
                    _musicState = MusicStates.Default;
                    PlayMusic();
                    return;
                }
                return;
            }
            else if (_musicState == MusicStates.FadeIn)
            {
                if (Fade(true))
                {
                    _musicState = MusicStates.Default;
                }
                return;
            }

            delay -= Time.unscaledDeltaTime;
            if (delay <= 0)
            {
                PlayMusic();
            }
        }