Esempio n. 1
0
        protected override void ProcessMsg(int key, QMsg msg)
        {
            switch (msg.msgId)
            {
            case (int)AudioEvent.SoundSwitch:
                AudioMsgWithBool soundSwitchMsg = msg as AudioMsgWithBool;
                SoundOn = soundSwitchMsg.on;
                break;

            case (int)AudioEvent.MusicSwitch:
                AudioMsgWithBool musicSwitchMsg = msg as AudioMsgWithBool;
                MusicOn = musicSwitchMsg.on;
                if (!MusicOn)
                {
                    StopMusic();
                }
                break;

            case (int)AudioEvent.PlayMusic:
                Debug.LogFormat("play music msg: {0}, is musicOn: ", AudioEvent.PlayMusic.ToString(), MusicOn);
                PlayMusic(msg as AudioMusicMsg);
                break;

            case (int)AudioEvent.StopMusic:
                StopMusic();
                break;

            case (int)AudioEvent.PlaySound:
                AudioSoundMsg audioSoundMsg = msg as AudioSoundMsg;
                PlaySound(audioSoundMsg);
                break;

            case (int)AudioEvent.PlayVoice:
                PlayVoice(msg as AudioVoiceMsg);
                break;

            case (int)AudioEvent.StopVoice:
                StopVoice();
                break;

            case (int)AudioEvent.PlayNode:
                IAction msgPlayNode = (msg as AudioMsgWithNode).Node;
                StartCoroutine(msgPlayNode.Execute());
                break;

            case (int)AudioEvent.AddRetainAudio:
                AddRetainAudioMsg addRetainAudioMsg = msg as AddRetainAudioMsg;
                AddRetainAudio(addRetainAudioMsg.AudioName);
                break;

            case (int)AudioEvent.RemoveRetainAudioAudio:
                RemoveRetainAudioMsg removeRetainAudioMsg = msg as RemoveRetainAudioMsg;
                RemoveRetainAudio(removeRetainAudioMsg.AudioName);
                break;
            }
        }
Esempio n. 2
0
        protected override void ProcessMsg(int key, QMsg msg)
        {
            switch (msg.EventID)
            {
            case (int)AudioEvent.SoundSwitch:
                var soundSwitchMsg = msg as AudioMsgWithBool;
                AudioKit.Settings.IsSoundOn.Value = soundSwitchMsg.on;
                break;

            case (int)AudioEvent.MusicSwitch:
                var musicSwitchMsg = msg as AudioMsgWithBool;
                AudioKit.Settings.IsMusicOn.Value = musicSwitchMsg.on;
                if (!AudioKit.Settings.IsMusicOn.Value)
                {
                    AudioKit.StopMusic();
                }

                break;

            case (int)AudioEvent.PlayMusic:
                Log.I("play music msg: {0}, is musicOn: {1}", AudioEvent.PlayMusic.ToString(),
                      AudioKit.Settings.IsMusicOn.Value);
                var musicMsg = msg as AudioMusicMsg;
                AudioKit.PlayMusic(musicMsg.MusicName, musicMsg.Loop, musicMsg.onMusicBeganCallback,
                                   musicMsg.onMusicEndedCallback, musicMsg.allowMusicOff);
                break;

            case (int)AudioEvent.StopMusic:
                AudioKit.StopMusic();
                break;

            case (int)AudioEvent.PlaySound:
                AudioSoundMsg audioSoundMsg = msg as AudioSoundMsg;
                PlaySound(audioSoundMsg);
                break;

            case (int)AudioEvent.PlayVoice:
                var voiceMsg = msg as AudioVoiceMsg;
                AudioKit.PlayVoice(voiceMsg.voiceName, voiceMsg.loop, voiceMsg.onVoiceBeganCallback,
                                   voiceMsg.onVoiceEndedCallback);
                break;

            case (int)AudioEvent.StopVoice:
                AudioKit.StopVoice();
                break;

            case (int)AudioEvent.PlayNode:
                var msgPlayNode = (msg as AudioMsgWithNode).Node;
                StartCoroutine(msgPlayNode.Execute());
                break;

            case (int)AudioEvent.AddRetainAudio:
                AddRetainAudioMsg addRetainAudioMsg = msg as AddRetainAudioMsg;
                AddRetainAudio(addRetainAudioMsg.AudioName);
                break;

            case (int)AudioEvent.RemoveRetainAudioAudio:
                RemoveRetainAudioMsg removeRetainAudioMsg = msg as RemoveRetainAudioMsg;
                RemoveRetainAudio(removeRetainAudioMsg.AudioName);
                break;

            case (int)AudioEvent.PauseMusic:
                AudioKit.PauseMusic();
                break;

            case (int)AudioEvent.ResumeMusic:
                AudioKit.ResumeMusic();
                break;
            }
        }