상속: MonoBehaviour
예제 #1
0
 void OnEnable()
 {
     isGameOver = true;
     HUDbuttons.SetActive(false);
     SaveLoadPrefs.Load();
     StartCoroutine(MusicSettings.TurnOffMusic());
     StartCoroutine(Display());
 }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        au = gameObject.GetComponent <AudioSource>();
        if (PlayerPrefs.HasKey("audioSettings"))
        {
            PauseMenus.audioSettings = (PauseMenus.AudioSettings)System.Enum.Parse(typeof(PauseMenus.AudioSettings), PlayerPrefs.GetString("audioSettings"));
            switch (PauseMenus.audioSettings)
            {
            case PauseMenus.AudioSettings.Mono:
                gameObject.GetComponent <AudioHighPassFilter>().enabled = true;
                break;

            case PauseMenus.AudioSettings.Stereo:
                gameObject.GetComponent <AudioHighPassFilter>().enabled = false;
                break;
            }
            StartCoroutine(MusicSettings.TurnOnMusic());
        }
    }
예제 #3
0
 public void UpdateSettings(ulong id, MusicSettings musicSettings)
 {
     _musicSettings.AddOrUpdate(id, musicSettings, delegate { return(musicSettings); });
 }
예제 #4
0
        public async Task <MusicPlayer> GetOrCreatePlayer(ulong guildId, IVoiceChannel voiceCh, ITextChannel textCh)
        {
            string GetText(string text, params object[] replacements) =>
            _strings.GetText(text, _localization.GetCultureInfo(textCh.Guild), "Music".ToLowerInvariant(), replacements);

            if (voiceCh == null || voiceCh.Guild != textCh.Guild)
            {
                if (textCh != null)
                {
                    await textCh.SendErrorAsync(GetText("must_be_in_voice")).ConfigureAwait(false);
                }
                throw new NotInVoiceChannelException();
            }
            return(MusicPlayers.GetOrAdd(guildId, _ =>
            {
                var vol = GetDefaultVolume(guildId);
                if (!_musicSettings.TryGetValue(guildId, out var ms))
                {
                    ms = new MusicSettings();
                }

                var mp = new MusicPlayer(this, ms, _google, voiceCh, textCh, vol);

                IUserMessage playingMessage = null;
                IUserMessage lastFinishedMessage = null;

                mp.OnCompleted += async(s, song) =>
                {
                    try
                    {
                        lastFinishedMessage?.DeleteAfter(0);

                        try
                        {
                            lastFinishedMessage = await mp.OutputTextChannel.EmbedAsync(new EmbedBuilder().WithOkColor()
                                                                                        .WithAuthor(eab => eab.WithName(GetText("finished_song")).WithMusicIcon())
                                                                                        .WithDescription(song.PrettyName)
                                                                                        .WithFooter(ef => ef.WithText(song.PrettyInfo)))
                                                  .ConfigureAwait(false);
                        }
                        catch
                        {
                            // ignored
                        }

                        var(Index, Current) = mp.Current;
                        if (Current == null &&
                            !mp.RepeatCurrentSong &&
                            !mp.RepeatPlaylist &&
                            !mp.FairPlay &&
                            AutoDcServers.Contains(guildId))
                        {
                            await DestroyPlayer(guildId).ConfigureAwait(false);
                        }
                    }
                    catch
                    {
                        // ignored
                    }
                };
                mp.OnStarted += async(player, song) =>
                {
                    //try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); }
                    //catch
                    //{
                    //    // ignored
                    //}
                    var sender = player;
                    if (sender == null)
                    {
                        return;
                    }
                    try
                    {
                        playingMessage?.DeleteAfter(0);

                        playingMessage = await mp.OutputTextChannel.EmbedAsync(new EmbedBuilder().WithOkColor()
                                                                               .WithAuthor(eab => eab.WithName(GetText("playing_song", song.Index + 1)).WithMusicIcon())
                                                                               .WithDescription(song.Song.PrettyName)
                                                                               .WithFooter(ef => ef.WithText(mp.PrettyVolume + " | " + song.Song.PrettyInfo)))
                                         .ConfigureAwait(false);
                    }
                    catch
                    {
                        // ignored
                    }
                };
                mp.OnPauseChanged += async(player, paused) =>
                {
                    try
                    {
                        IUserMessage msg;
                        if (paused)
                        {
                            msg = await mp.OutputTextChannel.SendConfirmAsync(GetText("paused")).ConfigureAwait(false);
                        }
                        else
                        {
                            msg = await mp.OutputTextChannel.SendConfirmAsync(GetText("resumed")).ConfigureAwait(false);
                        }

                        msg?.DeleteAfter(10);
                    }
                    catch
                    {
                        // ignored
                    }
                };
                _log.Info("Done creating");
                return mp;
            }));
        }
예제 #5
0
 public MusicInfo(MusicSettings settings, AudioSource source)
 {
     m_MusicSettings = settings;
     m_MusicEntry    = settings.m_MusicEntry;
     m_MusicSource   = source;
 }
예제 #6
0
 public bool Equals(MusicSettings musicSettings)
 {
     return(Mathf.RoundToInt(musicSettings.lowPass) == Mathf.RoundToInt(lowPass));
 }
예제 #7
0
 public void ApplyMusicSettings(MusicSettings settings)
 {
     masterMixer.SetFloat("Lowpass", settings.lowPass);
 }