Exemplo n.º 1
0
 public void Enqueue(PlayData resource)
 {
     Random = false;
     Loop   = false;
     mode   = PlaylistMode.Queue;
     playQueue.Enqueue(resource);
 }
Exemplo n.º 2
0
 public RadioDeskPlaylist()
 {
     this.itms      = new List <string>();
     this.cur_count = this.itms.Count;
     this.cur_pos   = 0;
     this.cur_mode  = PlaylistMode.Normal;
 }
Exemplo n.º 3
0
		public void Enqueue(PlayData resource)
		{
			Random = false;
			Loop = false;
			mode = PlaylistMode.Queue;
			playQueue.Enqueue(resource);
		}
Exemplo n.º 4
0
    void PlayPlayList(List <AudioClip> musicTracks, PlaylistMode playlistMode)
    {
        bool repeatMusic = false;

        m_PlaylistMode = playlistMode;

        if (m_PlaylistMode == PlaylistMode.Shuffle)
        {
            CreateShufflePlaylist(musicTracks);
        }

        if (m_PlaylistMode == PlaylistMode.Random)
        {
            repeatMusic = true;
            StartCoroutine(PlayInRandomOrder(musicTracks, repeatMusic));
        }

        if (m_PlaylistMode == PlaylistMode.RandomNoRepeat)
        {
            repeatMusic = false;
            StartCoroutine(PlayInRandomOrder(musicTracks, repeatMusic));
        }

        if (m_PlaylistMode == PlaylistMode.InOrder)
        {
            StartCoroutine(PlayInOrder(musicTracks, m_FadeInSong, m_FadeOutSong));
        }
    }
Exemplo n.º 5
0
    //Todo: Called from GameMaster
    public void StartAudio()
    {
        Speaker = GetComponent <AudioSource>();
        Speaker.spatialBlend = 1;
        Speaker.rolloffMode  = AudioRolloffMode.Linear;
        Speaker.minDistance  = 1;
        Speaker.maxDistance  = 25;
        Speaker.dopplerLevel = 0;
        Speaker.volume       = (Rm_GameConfig.Instance.Audio.MusicVolume / 100.0F) *
                               (Rm_GameConfig.Instance.Audio.MasterVolume / 100.0F);

        CurrentPlaylist     = GlobalPlaylist;
        CurrentPlayListMode = PlaylistMode.Global;

        bool playSceneMusic = false;

        //figure out playlist
        if (Rm_RPGHandler.Instance.Audio.PlayUniqueMusicForScenes)
        {
            var loadedScene   = SceneManager.GetActiveScene().name;
            var allSceneMusic = SceneLists.Where(s => s.SceneName == loadedScene).ToList();
            if (allSceneMusic.Count > 0)
            {
                playSceneMusic      = true;
                CurrentPlaylist     = allSceneMusic.Select(a => a.Music).ToList();
                CurrentPlayListMode = PlaylistMode.Scene;
            }
        }

        if (CurrentPlaylist.Count > 0 && (!Playing || playSceneMusic))
        {
            if (Rm_RPGHandler.Instance.Audio.ShufflePlaylist)
            {
                CurrentSong = Random.Range(0, CurrentPlaylist.Count);
            }
            else
            {
                CurrentSong = 0;
            }

            StartCoroutine("PlayMusic", false);
        }
    }
Exemplo n.º 6
0
        private GlobalConfig()
        {
            const string configFile = "Config.yaml";

            using (StreamReader fileStream = File.OpenText(Utils.CombineWithBaseDirectory(configFile)))
            {
                try
                {
                    var yaml = new YamlStream();
                    yaml.Load(fileStream);

                    var mapping = (YamlMappingNode)yaml.Documents[0].RootNode;
                    TaskbarProgress             = mapping.GetValidBoolean(nameof(TaskbarProgress));
                    RefreshRate                 = (ushort)mapping.GetValidValue(nameof(RefreshRate), 1, 1000);
                    CenterIndicators            = mapping.GetValidBoolean(nameof(CenterIndicators));
                    PanpotIndicators            = mapping.GetValidBoolean(nameof(PanpotIndicators));
                    PlaylistMode                = mapping.GetValidEnum <PlaylistMode>(nameof(PlaylistMode));
                    PlaylistSongLoops           = mapping.GetValidValue(nameof(PlaylistSongLoops), 0, long.MaxValue);
                    PlaylistFadeOutMilliseconds = mapping.GetValidValue(nameof(PlaylistFadeOutMilliseconds), 0, long.MaxValue);
                    MiddleCOctave               = (sbyte)mapping.GetValidValue(nameof(MiddleCOctave), sbyte.MinValue, sbyte.MaxValue);

                    var cmap = (YamlMappingNode)mapping.Children[nameof(Colors)];
                    Colors = new HSLColor[256];
                    foreach (KeyValuePair <YamlNode, YamlNode> c in cmap)
                    {
                        int i = (int)Utils.ParseValue(string.Format(Strings.ConfigKeySubkey, nameof(Colors)), c.Key.ToString(), 0, 127);
                        if (Colors[i] != null)
                        {
                            throw new Exception(string.Format(Strings.ErrorParseConfig, configFile, Environment.NewLine + string.Format(Strings.ErrorConfigColorRepeated, i)));
                        }
                        double h = 0, s = 0, l = 0;
                        foreach (KeyValuePair <YamlNode, YamlNode> v in ((YamlMappingNode)c.Value).Children)
                        {
                            string key       = v.Key.ToString();
                            string valueName = string.Format(Strings.ConfigKeySubkey, string.Format("{0} {1}", nameof(Colors), i));
                            if (key == "H")
                            {
                                h = Utils.ParseValue(valueName, v.Value.ToString(), 0, 240);
                            }
                            else if (key == "S")
                            {
                                s = Utils.ParseValue(valueName, v.Value.ToString(), 0, 240);
                            }
                            else if (key == "L")
                            {
                                l = Utils.ParseValue(valueName, v.Value.ToString(), 0, 240);
                            }
                            else
                            {
                                throw new Exception(string.Format(Strings.ErrorParseConfig, configFile, Environment.NewLine + string.Format(Strings.ErrorConfigColorInvalidKey, i)));
                            }
                        }
                        var co = new HSLColor(h, s, l);
                        Colors[i]       = co;
                        Colors[i + 128] = co;
                    }
                    for (int i = 0; i < Colors.Length; i++)
                    {
                        if (Colors[i] == null)
                        {
                            throw new Exception(string.Format(Strings.ErrorParseConfig, configFile, Environment.NewLine + string.Format(Strings.ErrorConfigColorMissing, i)));
                        }
                    }
                }
                catch (BetterKeyNotFoundException ex)
                {
                    throw new Exception(string.Format(Strings.ErrorParseConfig, configFile, Environment.NewLine + string.Format(Strings.ErrorConfigKeyMissing, ex.Key)));
                }
                catch (Exception ex) when(ex is InvalidValueException || ex is YamlDotNet.Core.YamlException)
                {
                    throw new Exception(string.Format(Strings.ErrorParseConfig, configFile, Environment.NewLine + ex.Message));
                }
            }
        }
Exemplo n.º 7
0
    void Update()
    {
        if (HaveBattleMusic() && GetObject.PlayerMono != null && GetObject.PlayerMono.Controller.InCombat && !SwitchedToBattle)     //switched to battle
        {
            SwitchedToBattle     = true;
            PrevSongTimeSamples  = Speaker.timeSamples;
            PrevSongIndex        = CurrentSong;
            PrevSongPlaylist     = CurrentPlaylist;
            PrevSongPlaylistMode = CurrentPlayListMode;

            StopMusic();

            CurrentPlaylist     = Rm_RPGHandler.Instance.Audio.BattlePlaylist;
            CurrentPlayListMode = PlaylistMode.Battle;
            CurrentSong         = 0;

            StartCoroutine("PlayMusic", false);
        }

        //todo: cinematics
        if (HaveBattleMusic() && GetObject.PlayerMono != null && !GetObject.PlayerMono.Controller.InCombat && SwitchedToBattle)
        {
            SwitchedToBattle    = false;
            CurrentPlaylist     = PrevSongPlaylist;
            CurrentPlayListMode = PrevSongPlaylistMode;
            CurrentSong         = PrevSongIndex;
            StopMusic();
            StartCoroutine("PlayMusic", true);
        }

        if (HaveDeathMusic() && GetObject.PlayerMono != null && !GetObject.PlayerMono.Character.Alive && !PlayedDeathMusic)     //switched to battle
        {
            if (SwitchedToBattle)
            {
                SwitchedToBattle    = false;
                CurrentPlaylist     = PrevSongPlaylist;
                CurrentPlayListMode = PrevSongPlaylistMode;
                CurrentSong         = PrevSongIndex;
                StopMusic();
            }

            PlayedDeathMusic     = true;
            PrevSongTimeSamples  = Speaker.timeSamples;
            PrevSongIndex        = CurrentSong;
            PrevSongPlaylist     = CurrentPlaylist;
            PrevSongPlaylistMode = CurrentPlayListMode;

            StopMusic();

            CurrentPlaylist = new List <AudioContainer>()
            {
                DeathMusic
            };
            CurrentPlayListMode = PlaylistMode.Death;
            CurrentSong         = 0;

            StartCoroutine("PlayMusic", false);
        }

        if (HaveDeathMusic() && GetObject.PlayerMono != null && GetObject.PlayerMono.Character.Alive && PlayedDeathMusic)     //switched to battle
        {
            PlayedDeathMusic = false;
            StopMusic();
            FadeMusic   = false;
            FadeMusicIn = true;
            StartAudio();
        }

        if (FadeMusic)
        {
            Speaker.volume -= (MusicVolume / Rm_RPGHandler.Instance.Audio.FadeOutTime) * Time.deltaTime;
        }
        else if (FadeMusicIn)
        {
            Speaker.volume += (MusicVolume / Rm_RPGHandler.Instance.Audio.FadeInTime) * Time.deltaTime;
        }
        else
        {
            Speaker.volume = MusicVolume;
        }

        if (GameMaster.CutsceneActive)
        {
            Speaker.Pause();
        }
        else
        {
            Speaker.UnPause();
        }
    }