Exemplo 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;
            }
        }
Exemplo n.º 2
0
        protected override void ProcessMsg(int key, QMsg msg)
        {
            switch (msg.msgId)
            {
            case (ushort)AudioEvent.SoundSwitch:
                AudioMsgWithBool soundSwitchMsg = msg as AudioMsgWithBool;
                mSoundOn = soundSwitchMsg.on;
                break;

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

            case (ushort)AudioEvent.PlayMusic:
                Debug.LogFormat("play music msg: {0}, is musicOn: ", AudioEvent.PlayMusic.ToString(), mMusicOn);
                PlayMusic(msg as AudioMsgPlayMusic);
                break;

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

            case (ushort)AudioEvent.PlaySound:
                AudioMsgPlaySound audioMsgPlaySound = msg as AudioMsgPlaySound;
                PlaySound(audioMsgPlaySound);
                break;

            case (ushort)AudioEvent.PlayVoice:
                PlayVoice(msg as AudioMsgPlayVoice);
                break;

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

            case (ushort)AudioEvent.PlayNode:
                ICoroutineCmdNode msgPlayNode = (msg as AudioMsgWithNode).Node;

                StartCoroutine(msgPlayNode.Execute());
                break;
            }
        }