Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.M))
        {
            switch (mode)
            {
            case MusicMode.FULL:
                speaker.volume = 0.0f;
                mode           = MusicMode.MUTE;
                PlayerPrefs.SetInt("Music", (int)MusicMode.MUTE);
                break;

            case MusicMode.MUTE:
                speaker.volume = 0.5f;
                mode           = MusicMode.HALF;
                PlayerPrefs.SetInt("Music", (int)MusicMode.HALF);
                break;

            case MusicMode.HALF:
                speaker.volume = 1.0f;
                mode           = MusicMode.FULL;
                PlayerPrefs.SetInt("Music", (int)MusicMode.FULL);
                break;
            }
        }
    }
Ejemplo n.º 2
0
    IEnumerator MusicVolume(MusicMode musicMode)
    {
        switch (musicMode)
        {
        case MusicMode.noSound:
        {
            GetComponentInChildren <AudioSource>().Stop();
            break;
        }

        case MusicMode.fadeDown:
        {
            GetComponentInChildren <AudioSource>().volume -= Time.deltaTime / 3;
            break;
        }

        case MusicMode.musicOn:
        {
            if (GetComponentInChildren <AudioSource>().clip != null)
            {
                GetComponentInChildren <AudioSource>().Play();
                GetComponentInChildren <AudioSource>().volume = 1;
            }
            break;
        }
        }
        yield return(new WaitForSeconds(0.1f));
    }
Ejemplo n.º 3
0
 public void SetMusic(Socket sender, uint musicId, MusicMode mode = MusicMode.Play)
 {
     byte[] data = new byte[0x08];
     data[0]    = (byte)musicId; //these numbers will not vary, so no need for blockcopy
     data[0x02] = (byte)mode;
     SendPacket(sender, ServerOpcode.SetMusic, data);
 }
Ejemplo n.º 4
0
        public MusicManager(MusicMode mode)
        {
            this.mode = mode;

            if (mode == MusicMode.Offline)
            {
                if (!Directory.Exists(MusicManager.MusicPath))
                {
                    Directory.CreateDirectory(MusicManager.MusicPath);
                }
            }
            else if (mode == MusicMode.Online)
            {
                if (!File.Exists(MusicManager.OnlineMusicFile))
                {
                    StringBuilder builder = new StringBuilder();
                    using (StreamWriter writer = File.CreateText(MusicManager.OnlineMusicFile))
                    {
                        writer.WriteLine(builder.ToString());
                    }
                }

                this.onlineTracks = new Dictionary<string, List<string>>();
                this.ProcessOnlineIni();

            }

            this.watcher = new FileSystemWatcher(Directory.GetCurrentDirectory());
            this.watcher.Filter = MusicManager.OnlineMusicFile;
            this.watcher.NotifyFilter = NotifyFilters.LastWrite;
            this.watcher.EnableRaisingEvents = true;
            this.watcher.Changed += FileSystemChangeEvent;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Plays the specified sound sample, looping until stop.
        /// Stops any existing loop.
        /// </summary>
        public static void Loop(SoundSample sound, long position = 0)
        {
            if (sound == Sound.Music1)
            {
                _musicMode = MusicMode.Music1;
            }
            else if (sound == Sound.Music2)
            {
                _musicMode = MusicMode.Music2;
            }
            else
            {
                _musicMode = MusicMode.None;
            }

            if ((sound.IsMusic) && (!GameConfig.Instance.Music))
            {
                return;
            }
            if ((!sound.IsMusic) && (!GameConfig.Instance.SoundEffects))
            {
                return;
            }

            _manager?.PlayLoop(id: sound.ID, stopOtherLoops: true, position: position);
        }
Ejemplo n.º 6
0
        private void ToggleButton(MusicMode type)
        {
            if (Main.musicVolume > 0f)
            {
                switch (type)
                {
                case MusicMode.Play:
                    if (!listening)
                    {
                        playingMusic = (playingMusic == -1) ? tMusicPlayer.AllMusic[DisplayBox].music : -1;
                        if (playingMusic != -1)
                        {
                            listening = false;
                        }
                        break;
                    }
                    return;

                case MusicMode.Listen:
                    listening = !listening;
                    if (listening)
                    {
                        playingMusic = -1;
                    }
                    else
                    {
                        recording = false;
                    }
                    break;

                case MusicMode.Record:
                    recording = !recording;
                    if (recording)
                    {
                        recording = (Main.LocalPlayer.GetModPlayer <MusicPlayerPlayer>().musicBoxesStored > 0);
                    }
                    if (recording)
                    {
                        listening = true;
                    }
                    break;
                }
                if (tMusicPlayer.tMPConfig.EnableDebugMode)
                {
                    string green = Utils.Hex3(Color.ForestGreen);
                    string red   = Utils.Hex3(Color.IndianRed);
                    tMusicPlayer.SendDebugText($"[c/{(playingMusic > -1 ? green : red)}:Playing] - [c/{(listening ? green : red)}:Listening] - [c/{(recording ? green : red)}:Recording]");
                }
            }
        }
Ejemplo n.º 7
0
        public static void Play(MusicMode mode, MusicMood mood)
        {
            if (mode == CurrentMode && mood == CurrentMood)
            {
                return;
            }
            if (linux)
            {
                return;
            }

            currentMode = mode;
            currentMood = mood;
            StartNewTrack();
        }
Ejemplo n.º 8
0
    public void SwitchMusic(MusicMode mode = MusicMode.Simple, bool forceStop = false)
    {
        if (mode <= currentMode && !forceStop)
        {
            return;
        }

        StopAllCoroutines();
        StartCoroutine(LoopMusic(
                           mode switch
        {
            MusicMode.Medium => inGameMusic_2,
            MusicMode.Heavy => inGameMusic_3,
            _ => inGameMusic_1,
        }, forceStop));
Ejemplo n.º 9
0
    public void IsAttacking()
    {
        spiritState = SpiritState.Attack;
        if (!screamed)
        {
            MusicMode musicSetting = (MusicMode)PlayerPrefs.GetInt("Music", 0);
            switch (musicSetting)
            {
            case MusicMode.FULL:
                speaker.volume = 1.0f;
                break;

            case MusicMode.MUTE:
                speaker.volume = 0f;
                break;

            case MusicMode.HALF:
                speaker.volume = 0.5f;
                break;
            }
            speaker.PlayOneShot(scream_sfx);
            screamed = true;
        }
    }
Ejemplo n.º 10
0
        public void tryPlayMusic()
        {
            //尝试播放音乐
            var firstInfo = m_demandMusicQue.First();

            if (firstInfo != null)
            {
                m_curMusicMode = MusicMode.DemandMusic;            //点歌模式
                if (firstInfo.Status == DemandSongStatus.WaitPlay) //队列第一个刚好是等待播放状态
                {
                    m_musicPlayer.Play(firstInfo.QueueId, firstInfo.SongInfo.FileName);
                }
            }
            else //自定义音乐播放模式
            {
                var musicNum = m_localMusicList.Count;

                if (musicNum == 0)
                {
                    m_curMusicMode = MusicMode.Invalid; //无效状态
                    return;
                }

                m_curMusicMode = MusicMode.LocalMusic; //本地音乐

                var musicIdx = -1;

                if (m_localMusicIdx == -1) //初始化
                {
                    musicIdx = 0;
                }
                else
                {
                    musicIdx = m_localMusicIdx + 1; //下一曲
                    if (musicIdx >= musicNum)       //循环
                    {
                        musicIdx = 0;
                    }
                }

                m_localMusicIdx = musicIdx;

                //生成信息
                string fileName   = (string)m_localMusicList[musicIdx];
                string musicName  = Path.GetFileNameWithoutExtension(fileName);
                var    demandInfo = new DemandInfo();
                demandInfo.Keyword      = musicName;
                demandInfo.QueueId      = genQueueId();
                demandInfo.UserName     = "******";
                demandInfo.Status       = DemandSongStatus.WaitPlay;
                demandInfo.IsLocalMusic = true;
                demandInfo.SongInfo     = new Song(null)
                {
                    Id = 0, FileName = fileName, Name = musicName
                };
                //加入队列
                m_demandMusicQue.Add(demandInfo);
                postDemandInfo(demandInfo);
                //播放音乐
                m_musicPlayer.Play(demandInfo.QueueId, fileName);
            }
        }
Ejemplo n.º 11
0
 public Track(MusicMode mode, MusicMood mood, string path)
 {
     Mode = mode;
     Mood = mood;
     Path = path;
 }
Ejemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     mode = (MusicMode)PlayerPrefs.GetInt("Music", 0);
     speaker.Play();
 }
        public void DeactivateCampaignMode()
        {
            int num = (int)PsaiCore.Instance.StopMusic(true, 3f);

            this.CurrentMode = MusicMode.Paused;
        }
 public void ActivateCampaignMode() => this.CurrentMode = MusicMode.Campaign;
 public void ActivateBattleMode() => this.CurrentMode = MusicMode.Battle;
        private void DeactivateMenuMode()
        {
            int num = (int)PsaiCore.Instance.MenuModeLeave();

            this.CurrentMode = MusicMode.Paused;
        }
 private void ActivateMenuMode()
 {
     this.CurrentMode = MusicMode.Menu;
     int num = (int)PsaiCore.Instance.MenuModeEnter(5, 0.5f);
 }