public void Clear()
 {
     m_SerialId        = 0;
     m_SoundGroup      = null;
     m_PlaySoundParams = null;
     m_UserData        = null;
 }
 public PlaySoundInfo()
 {
     m_SerialId        = 0;
     m_SoundGroup      = null;
     m_PlaySoundParams = null;
     m_UserData        = null;
 }
예제 #3
0
        /// <summary>
        /// 播放声音。
        /// </summary>
        /// <param name="soundAssetName">声音资源名称。</param>
        /// <param name="soundGroupName">声音组名称。</param>
        /// <param name="priority">加载声音资源的优先级。</param>
        /// <param name="playSoundParams">播放声音参数。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>声音的序列编号。</returns>
        public int PlaySound(string soundAssetName, string soundGroupName, int priority, PlaySoundParams playSoundParams, object userData)
        {
            if (m_ResourceManager == null)
            {
                throw new GameFrameworkException("You must set resource manager first.");
            }

            if (m_SoundHelper == null)
            {
                throw new GameFrameworkException("You must set sound helper first.");
            }

            if (playSoundParams == null)
            {
                playSoundParams = PlaySoundParams.Create();
            }

            int serialId = ++m_Serial;
            PlaySoundErrorCode?errorCode    = null;
            string             errorMessage = null;
            SoundGroup         soundGroup   = (SoundGroup)GetSoundGroup(soundGroupName);

            if (soundGroup == null)
            {
                errorCode    = PlaySoundErrorCode.SoundGroupNotExist;
                errorMessage = Utility.Text.Format("Sound group '{0}' is not exist.", soundGroupName);
            }
            else if (soundGroup.SoundAgentCount <= 0)
            {
                errorCode    = PlaySoundErrorCode.SoundGroupHasNoAgent;
                errorMessage = Utility.Text.Format("Sound group '{0}' is have no sound agent.", soundGroupName);
            }

            if (errorCode.HasValue)
            {
                if (m_PlaySoundFailureEventHandler != null)
                {
                    PlaySoundFailureEventArgs playSoundFailureEventArgs = PlaySoundFailureEventArgs.Create(serialId, soundAssetName, soundGroupName, playSoundParams, errorCode.Value, errorMessage, userData);
                    m_PlaySoundFailureEventHandler(this, playSoundFailureEventArgs);
                    ReferencePool.Release(playSoundFailureEventArgs);

                    if (playSoundParams.Referenced)
                    {
                        ReferencePool.Release(playSoundParams);
                    }

                    return(serialId);
                }

                throw new GameFrameworkException(errorMessage);
            }

            m_SoundsBeingLoaded.Add(serialId);
            m_ResourceManager.LoadAsset(soundAssetName, priority, m_LoadAssetCallbacks, PlaySoundInfo.Create(serialId, soundGroup, playSoundParams, userData));
            return(serialId);
        }
            public static PlaySoundInfo Create(int serialId, SoundGroup soundGroup, PlaySoundParams playSoundParams, object userData)
            {
                PlaySoundInfo playSoundInfo = ReferencePool.Acquire <PlaySoundInfo>();

                playSoundInfo.m_SerialId        = serialId;
                playSoundInfo.m_SoundGroup      = soundGroup;
                playSoundInfo.m_PlaySoundParams = playSoundParams;
                playSoundInfo.m_UserData        = userData;
                return(playSoundInfo);
            }
            /// <summary>
            /// 播放声音。
            /// </summary>
            /// <param name="serialId">声音的序列编号。</param>
            /// <param name="soundAsset">声音资源。</param>
            /// <param name="playSoundParams">播放声音参数。</param>
            /// <param name="errorCode">错误码。</param>
            /// <returns>用于播放的声音代理。</returns>
            public ISoundAgent PlaySound(int serialId, object soundAsset, PlaySoundParams playSoundParams, out PlaySoundErrorCode?errorCode)
            {
                errorCode = null;
                SoundAgent candidateAgent = null;

                foreach (SoundAgent soundAgent in m_SoundAgents)
                {
                    if (!soundAgent.IsPlaying)
                    {
                        candidateAgent = soundAgent;
                        break;
                    }

                    if (soundAgent.Priority < playSoundParams.Priority)
                    {
                        if (candidateAgent == null || soundAgent.Priority < candidateAgent.Priority)
                        {
                            candidateAgent = soundAgent;
                        }
                    }
                    else if (!m_AvoidBeingReplacedBySamePriority && soundAgent.Priority == playSoundParams.Priority)
                    {
                        if (candidateAgent == null || soundAgent.SetSoundAssetTime < candidateAgent.SetSoundAssetTime)
                        {
                            candidateAgent = soundAgent;
                        }
                    }
                }

                if (candidateAgent == null)
                {
                    errorCode = PlaySoundErrorCode.IgnoredDueToLowPriority;
                    return(null);
                }

                if (!candidateAgent.SetSoundAsset(soundAsset))
                {
                    errorCode = PlaySoundErrorCode.SetSoundAssetFailure;
                    return(null);
                }

                candidateAgent.SerialId           = serialId;
                candidateAgent.Time               = playSoundParams.Time;
                candidateAgent.MuteInSoundGroup   = playSoundParams.MuteInSoundGroup;
                candidateAgent.Loop               = playSoundParams.Loop;
                candidateAgent.Priority           = playSoundParams.Priority;
                candidateAgent.VolumeInSoundGroup = playSoundParams.VolumeInSoundGroup;
                candidateAgent.Pitch              = playSoundParams.Pitch;
                candidateAgent.PanStereo          = playSoundParams.PanStereo;
                candidateAgent.SpatialBlend       = playSoundParams.SpatialBlend;
                candidateAgent.MaxDistance        = playSoundParams.MaxDistance;
                candidateAgent.DopplerLevel       = playSoundParams.DopplerLevel;
                candidateAgent.Play(playSoundParams.FadeInSeconds);
                return(candidateAgent);
            }
예제 #6
0
        /// <summary>
        /// 播放声音。
        /// </summary>
        /// <param name="soundAssetName">声音资源名称。</param>
        /// <param name="soundGroupName">声音组名称。</param>
        /// <param name="playSoundParams">播放声音参数。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>声音的序列编号。</returns>
        public int PlaySound(string soundAssetName, string soundGroupName, PlaySoundParams playSoundParams, object userData)
        {
            if (m_ResourceManager == null)
            {
                throw new GameFrameworkException("You must set resource manager first.");
            }

            if (m_SoundHelper == null)
            {
                throw new GameFrameworkException("You must set sound helper first.");
            }

            if (playSoundParams == null)
            {
                playSoundParams = new PlaySoundParams();
            }

            int serialId = m_Serial++;
            PlaySoundErrorCode?errorCode    = null;
            string             errorMessage = null;
            SoundGroup         soundGroup   = (SoundGroup)GetSoundGroup(soundGroupName);

            if (soundGroup == null)
            {
                errorCode    = PlaySoundErrorCode.SoundGroupNotExist;
                errorMessage = string.Format("Sound group '{0}' is not exist.", soundGroupName);
            }
            else if (soundGroup.SoundAgentCount <= 0)
            {
                errorCode    = PlaySoundErrorCode.SoundGroupHasNoAgent;
                errorMessage = string.Format("Sound group '{0}' is have no sound agent.", soundGroupName);
            }

            if (errorCode.HasValue)
            {
                if (m_PlaySoundFailureEventHandler != null)
                {
                    m_PlaySoundFailureEventHandler(this, new PlaySoundFailureEventArgs(serialId, soundAssetName, soundGroupName, playSoundParams, errorCode.Value, errorMessage, userData));
                    return(serialId);
                }

                throw new GameFrameworkException(errorMessage);
            }

            m_SoundsBeingLoaded.Add(serialId);
            m_ResourceManager.LoadAsset(soundAssetName, m_LoadAssetCallbacks, new PlaySoundInfo(serialId, soundGroup, playSoundParams, userData));
            return(serialId);
        }
    static int get_Loop(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            GameFramework.Sound.PlaySoundParams obj = (GameFramework.Sound.PlaySoundParams)o;
            bool ret = obj.Loop;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Loop on a nil value" : e.Message));
        }
    }
    static int get_Time(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            GameFramework.Sound.PlaySoundParams obj = (GameFramework.Sound.PlaySoundParams)o;
            float ret = obj.Time;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Time on a nil value" : e.Message));
        }
    }
    static int set_MaxDistance(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            GameFramework.Sound.PlaySoundParams obj = (GameFramework.Sound.PlaySoundParams)o;
            float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.MaxDistance = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index MaxDistance on a nil value" : e.Message));
        }
    }
    static int set_Loop(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            GameFramework.Sound.PlaySoundParams obj = (GameFramework.Sound.PlaySoundParams)o;
            bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.Loop = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Loop on a nil value" : e.Message));
        }
    }
    static int get_Priority(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            GameFramework.Sound.PlaySoundParams obj = (GameFramework.Sound.PlaySoundParams)o;
            int ret = obj.Priority;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Priority on a nil value" : e.Message));
        }
    }
    static int _CreateGameFramework_Sound_PlaySoundParams(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                GameFramework.Sound.PlaySoundParams obj = new GameFramework.Sound.PlaySoundParams();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: GameFramework.Sound.PlaySoundParams.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #13
0
 /// <summary>
 /// 播放声音。
 /// </summary>
 /// <param name="soundAssetName">声音资源名称。</param>
 /// <param name="soundGroupName">声音组名称。</param>
 /// <param name="playSoundParams">播放声音参数。</param>
 /// <param name="userData">用户自定义数据。</param>
 /// <returns>声音的序列编号。</returns>
 public int PlaySound(string soundAssetName, string soundGroupName, PlaySoundParams playSoundParams, object userData)
 {
     return(PlaySound(soundAssetName, soundGroupName, Resource.Constant.DefaultPriority, playSoundParams, userData));
 }
예제 #14
0
 /// <summary>
 /// 播放声音。
 /// </summary>
 /// <param name="soundAssetName">声音资源名称。</param>
 /// <param name="soundGroupName">声音组名称。</param>
 /// <param name="priority">加载声音资源的优先级。</param>
 /// <param name="playSoundParams">播放声音参数。</param>
 /// <returns>声音的序列编号。</returns>
 public int PlaySound(string soundAssetName, string soundGroupName, int priority, PlaySoundParams playSoundParams)
 {
     return(PlaySound(soundAssetName, soundGroupName, priority, playSoundParams, null));
 }
예제 #15
0
 /// <summary>
 /// 播放声音。
 /// </summary>
 /// <param name="soundAssetName">声音资源名称。</param>
 /// <param name="soundGroupName">声音组名称。</param>
 /// <param name="playSoundParams">播放声音参数。</param>
 /// <returns>声音的序列编号。</returns>
 public int PlaySound(string soundAssetName, string soundGroupName, PlaySoundParams playSoundParams)
 {
     return(PlaySound(soundAssetName, soundGroupName, Resource.Constant.DefaultPriority, playSoundParams, null));
 }
예제 #16
0
 public int PlaySound(ResourceLoadInfo resourceLoadInfo, PlaySoundParams playSoundParams)
 {
     return(soundManager.PlaySound(resourceLoadInfo, playSoundParams));
 }
    static int PlaySound(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                int    o    = obj.PlaySound(arg0, arg1);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(UnityEngine.Vector3)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                UnityEngine.Vector3 arg2 = ToLua.ToVector3(L, 4);
                int o = obj.PlaySound(arg0, arg1, arg2);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(UnityGameFramework.Runtime.Entity)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                UnityGameFramework.Runtime.Entity arg2 = (UnityGameFramework.Runtime.Entity)ToLua.ToObject(L, 4);
                int o = obj.PlaySound(arg0, arg1, arg2);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(GameFramework.Sound.PlaySoundParams)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                GameFramework.Sound.PlaySoundParams arg2 = (GameFramework.Sound.PlaySoundParams)ToLua.ToObject(L, 4);
                int o = obj.PlaySound(arg0, arg1, arg2);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(object)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                object arg2 = ToLua.ToVarObject(L, 4);
                int    o    = obj.PlaySound(arg0, arg1, arg2);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(GameFramework.Sound.PlaySoundParams), typeof(UnityEngine.Vector3)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                GameFramework.Sound.PlaySoundParams arg2 = (GameFramework.Sound.PlaySoundParams)ToLua.ToObject(L, 4);
                UnityEngine.Vector3 arg3 = ToLua.ToVector3(L, 5);
                int o = obj.PlaySound(arg0, arg1, arg2, arg3);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(GameFramework.Sound.PlaySoundParams), typeof(UnityGameFramework.Runtime.Entity)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                GameFramework.Sound.PlaySoundParams arg2 = (GameFramework.Sound.PlaySoundParams)ToLua.ToObject(L, 4);
                UnityGameFramework.Runtime.Entity   arg3 = (UnityGameFramework.Runtime.Entity)ToLua.ToObject(L, 5);
                int o = obj.PlaySound(arg0, arg1, arg2, arg3);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(UnityEngine.Vector3), typeof(object)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                UnityEngine.Vector3 arg2 = ToLua.ToVector3(L, 4);
                object arg3 = ToLua.ToVarObject(L, 5);
                int    o    = obj.PlaySound(arg0, arg1, arg2, arg3);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(GameFramework.Sound.PlaySoundParams), typeof(object)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                GameFramework.Sound.PlaySoundParams arg2 = (GameFramework.Sound.PlaySoundParams)ToLua.ToObject(L, 4);
                object arg3 = ToLua.ToVarObject(L, 5);
                int    o    = obj.PlaySound(arg0, arg1, arg2, arg3);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(UnityGameFramework.Runtime.Entity), typeof(object)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                UnityGameFramework.Runtime.Entity arg2 = (UnityGameFramework.Runtime.Entity)ToLua.ToObject(L, 4);
                object arg3 = ToLua.ToVarObject(L, 5);
                int    o    = obj.PlaySound(arg0, arg1, arg2, arg3);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 6 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(GameFramework.Sound.PlaySoundParams), typeof(UnityEngine.Vector3), typeof(object)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                GameFramework.Sound.PlaySoundParams arg2 = (GameFramework.Sound.PlaySoundParams)ToLua.ToObject(L, 4);
                UnityEngine.Vector3 arg3 = ToLua.ToVector3(L, 5);
                object arg4 = ToLua.ToVarObject(L, 6);
                int    o    = obj.PlaySound(arg0, arg1, arg2, arg3, arg4);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 6 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(string), typeof(string), typeof(GameFramework.Sound.PlaySoundParams), typeof(UnityGameFramework.Runtime.Entity), typeof(object)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                GameFramework.Sound.PlaySoundParams arg2 = (GameFramework.Sound.PlaySoundParams)ToLua.ToObject(L, 4);
                UnityGameFramework.Runtime.Entity   arg3 = (UnityGameFramework.Runtime.Entity)ToLua.ToObject(L, 5);
                object arg4 = ToLua.ToVarObject(L, 6);
                int    o    = obj.PlaySound(arg0, arg1, arg2, arg3, arg4);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 7 && TypeChecker.CheckTypes(L, 1, typeof(UnityGameFramework.Runtime.SoundComponent), typeof(UnityEngine.Transform), typeof(string), typeof(UnityEngine.AudioClip), typeof(bool), typeof(bool), typeof(float)))
            {
                UnityGameFramework.Runtime.SoundComponent obj = (UnityGameFramework.Runtime.SoundComponent)ToLua.ToObject(L, 1);
                UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 2);
                string arg1 = ToLua.ToString(L, 3);
                UnityEngine.AudioClip arg2 = (UnityEngine.AudioClip)ToLua.ToObject(L, 4);
                bool  arg3 = LuaDLL.lua_toboolean(L, 5);
                bool  arg4 = LuaDLL.lua_toboolean(L, 6);
                float arg5 = (float)LuaDLL.lua_tonumber(L, 7);
                obj.PlaySound(arg0, arg1, arg2, arg3, arg4, arg5);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityGameFramework.Runtime.SoundComponent.PlaySound"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }