Ejemplo n.º 1
0
        public void OnSingletonInit()
        {
            Log.I("AudioManager OnSingletonInit");
            RegisterEvents(
                AudioEvent.SoundSwitch,
                AudioEvent.MusicSwitch,
                AudioEvent.VoiceSwitch,
                AudioEvent.SetSoundVolume,
                AudioEvent.SetMusicVolume,
                AudioEvent.SetVoiceVolume,
                AudioEvent.PlayMusic,
                AudioEvent.PlaySound,
                AudioEvent.PlayVoice,
                AudioEvent.PlayNode,
                AudioEvent.AddRetainAudio,
                AudioEvent.RemoveRetainAudioAudio
                );

            SafeObjectPool <AudioUnit> .Instance.Init(10, 1);

            mMainUnit            = AudioUnit.Allocate();
            mMainUnit.usedCache  = false;
            mVoiceUnit           = AudioUnit.Allocate();
            mVoiceUnit.usedCache = false;

            CheckAudioListener();

            gameObject.transform.position = Vector3.zero;

            // 读取存储
            ReadAudioSetting();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 播放音效
        /// </summary>
        void PlaySound(AudioSoundMsg soundMsg)
        {
            if (IsSoundOn)
            {
                AudioUnit unit = SafeObjectPool <AudioUnit> .Instance.Allocate();


                unit.SetOnStartListener(delegate(AudioUnit soundUnit)
                {
                    soundMsg.onSoundBeganCallback.InvokeGracefully();

                    unit.SetVolume(soundMsg.Volume);

                    unit.SetOnStartListener(null);
                });

                unit.SetAudio(gameObject, soundMsg.SoundName, false);

                unit.SetOnFinishListener(delegate(AudioUnit soundUnit)
                {
                    soundMsg.onSoundEndedCallback.InvokeGracefully();

                    unit.SetOnFinishListener(null);
                });
            }
        }
Ejemplo n.º 3
0
 public void Call(QFramework.AudioUnit param0)
 {
     func.BeginPCall();
     func.PushObject(param0);
     func.PCall();
     func.EndPCall();
 }
Ejemplo n.º 4
0
        public void OnSingletonInit()
        {
            ObjectPool <AudioUnit> .Instance.Init(mMaxSoundCount, 1);

            mMainUnit            = new AudioUnit();
            mMainUnit.usedCache  = false;
            mVoiceUnit           = new AudioUnit();
            mVoiceUnit.usedCache = false;
        }
Ejemplo n.º 5
0
        public AudioUnit PlaySound(bool loop = false, System.Action <AudioUnit> callBack = null, int customEventID = -1)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }

            AudioUnit unit = SafeObjectPool <AudioUnit> .Instance.Allocate();

            unit.SetAudio(gameObject, name, loop);
            unit.SetOnFinishListener(callBack);
            unit.customEventID = customEventID;
            return(unit);
        }
    static int PlaySound(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string arg0            = ToLua.CheckString(L, 1);
                QFramework.AudioUnit o = QFramework.AudioManager.PlaySound(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string arg0            = ToLua.CheckString(L, 1);
                bool   arg1            = LuaDLL.luaL_checkboolean(L, 2);
                QFramework.AudioUnit o = QFramework.AudioManager.PlaySound(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3)
            {
                string arg0 = ToLua.CheckString(L, 1);
                bool   arg1 = LuaDLL.luaL_checkboolean(L, 2);
                System.Action <QFramework.AudioUnit> arg2 = (System.Action <QFramework.AudioUnit>)ToLua.CheckDelegate <System.Action <QFramework.AudioUnit> >(L, 3);
                QFramework.AudioUnit o = QFramework.AudioManager.PlaySound(arg0, arg1, arg2);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 4)
            {
                string arg0 = ToLua.CheckString(L, 1);
                bool   arg1 = LuaDLL.luaL_checkboolean(L, 2);
                System.Action <QFramework.AudioUnit> arg2 = (System.Action <QFramework.AudioUnit>)ToLua.CheckDelegate <System.Action <QFramework.AudioUnit> >(L, 3);
                int arg3 = (int)LuaDLL.luaL_checknumber(L, 4);
                QFramework.AudioUnit o = QFramework.AudioManager.PlaySound(arg0, arg1, arg2, arg3);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: QFramework.AudioManager.PlaySound"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 7
0
        void SetVolume(AudioUnit audioUnit, VolumeLevel volumeLevel)
        {
            switch (volumeLevel)
            {
            case VolumeLevel.Max:
                audioUnit.SetVolume(1.0f);
                break;

            case VolumeLevel.Normal:
                audioUnit.SetVolume(0.5f);
                break;

            case VolumeLevel.Min:
                audioUnit.SetVolume(0.2f);
                break;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 播放音效
        /// </summary>
        void PlaySound(AudioMsgPlaySound msg)
        {
            AudioUnit unit = ObjectPool <AudioUnit> .Instance.Allocate();

            unit.SetOnStartListener(delegate(AudioUnit soundUnit)
            {
                if (null != msg.onSoundBeganCallback)
                {
                    msg.onSoundBeganCallback();
                }
                unit.SetOnStartListener(null);
            });

            unit.SetAudio(gameObject, msg.soundName, false);

            unit.SetOnFinishListener(delegate(AudioUnit soundUnit)
            {
                if (null != msg.onSoundEndedCallback)
                {
                    msg.onSoundEndedCallback();
                }
                unit.SetOnFinishListener(null);
            });
        }