static int AddOneDelegateToTimeCalc(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(TimeHelper), typeof(string), typeof(float), typeof(DelegateHelper.StringDelegate)))
            {
                TimeHelper obj  = (TimeHelper)ToLua.ToObject(L, 1);
                string     arg0 = ToLua.ToString(L, 2);
                float      arg1 = (float)LuaDLL.lua_tonumber(L, 3);
                DelegateHelper.StringDelegate arg2 = null;
                LuaTypes funcType4 = LuaDLL.lua_type(L, 4);

                if (funcType4 != LuaTypes.LUA_TFUNCTION)
                {
                    arg2 = (DelegateHelper.StringDelegate)ToLua.ToObject(L, 4);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 4);
                    arg2 = DelegateFactory.CreateDelegate(typeof(DelegateHelper.StringDelegate), func) as DelegateHelper.StringDelegate;
                }

                bool o = obj.AddOneDelegateToTimeCalc(arg0, arg1, arg2);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(TimeHelper), typeof(string), typeof(float), typeof(DelegateHelper.VoidDelegate)))
            {
                TimeHelper obj  = (TimeHelper)ToLua.ToObject(L, 1);
                string     arg0 = ToLua.ToString(L, 2);
                float      arg1 = (float)LuaDLL.lua_tonumber(L, 3);
                DelegateHelper.VoidDelegate arg2 = null;
                LuaTypes funcType4 = LuaDLL.lua_type(L, 4);

                if (funcType4 != LuaTypes.LUA_TFUNCTION)
                {
                    arg2 = (DelegateHelper.VoidDelegate)ToLua.ToObject(L, 4);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 4);
                    arg2 = DelegateFactory.CreateDelegate(typeof(DelegateHelper.VoidDelegate), func) as DelegateHelper.VoidDelegate;
                }

                bool o = obj.AddOneDelegateToTimeCalc(arg0, arg1, arg2);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: TimeHelper.AddOneDelegateToTimeCalc"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Add time calc dictionary item, delegate execute when time calc ends.
    /// </summary>
    /// <param name="key">item key</param>
    /// <param name="duration">time over duration</param>
    /// <param name="l_timeCalcVoidDelegate">delegate</param>
    /// <returns>is add succeed</returns>
    public bool AddOneDelegateToTimeCalc(string key, float duration, DelegateHelper.StringDelegate l_stringDelegate = null)
    {
        if (TimeCalc.ContainsKey(key))
        {
            Debug.LogError("Cannot add key:" + key + " to time calc cause key already exist.");
            return(false);
        }

        TimeCalc.m_timeCalcList.Add(new TimeCalc()
        {
            key = key, IsOverTime = true, StartTime = -1, OverTimeDuration = duration, m_TimeCalcStringDelegate = l_stringDelegate, DelegateMode = 2
        });

        StartCalc(key);
        return(true);
    }
Ejemplo n.º 3
0
 public static void AddListener(DelegateHelper.StringDelegate source, object dest)
 {
     source += (DelegateHelper.StringDelegate)dest;
 }
    static int AddListener(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(DelegateHelper.StringDelegate), typeof(object)))
            {
                DelegateHelper.StringDelegate arg0 = null;
                LuaTypes funcType1 = LuaDLL.lua_type(L, 1);

                if (funcType1 != LuaTypes.LUA_TFUNCTION)
                {
                    arg0 = (DelegateHelper.StringDelegate)ToLua.ToObject(L, 1);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 1);
                    arg0 = DelegateFactory.CreateDelegate(typeof(DelegateHelper.StringDelegate), func) as DelegateHelper.StringDelegate;
                }

                object arg1 = ToLua.ToVarObject(L, 2);
                LuaHelper.AddListener(arg0, arg1);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(DelegateHelper.TableDelegate), typeof(object)))
            {
                DelegateHelper.TableDelegate arg0 = null;
                LuaTypes funcType1 = LuaDLL.lua_type(L, 1);

                if (funcType1 != LuaTypes.LUA_TFUNCTION)
                {
                    arg0 = (DelegateHelper.TableDelegate)ToLua.ToObject(L, 1);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 1);
                    arg0 = DelegateFactory.CreateDelegate(typeof(DelegateHelper.TableDelegate), func) as DelegateHelper.TableDelegate;
                }

                object arg1 = ToLua.ToVarObject(L, 2);
                LuaHelper.AddListener(arg0, arg1);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(DelegateHelper.FloatDelegate), typeof(object)))
            {
                DelegateHelper.FloatDelegate arg0 = null;
                LuaTypes funcType1 = LuaDLL.lua_type(L, 1);

                if (funcType1 != LuaTypes.LUA_TFUNCTION)
                {
                    arg0 = (DelegateHelper.FloatDelegate)ToLua.ToObject(L, 1);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 1);
                    arg0 = DelegateFactory.CreateDelegate(typeof(DelegateHelper.FloatDelegate), func) as DelegateHelper.FloatDelegate;
                }

                object arg1 = ToLua.ToVarObject(L, 2);
                LuaHelper.AddListener(arg0, arg1);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(DelegateHelper.VoidDelegate), typeof(object)))
            {
                DelegateHelper.VoidDelegate arg0 = null;
                LuaTypes funcType1 = LuaDLL.lua_type(L, 1);

                if (funcType1 != LuaTypes.LUA_TFUNCTION)
                {
                    arg0 = (DelegateHelper.VoidDelegate)ToLua.ToObject(L, 1);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 1);
                    arg0 = DelegateFactory.CreateDelegate(typeof(DelegateHelper.VoidDelegate), func) as DelegateHelper.VoidDelegate;
                }

                object arg1 = ToLua.ToVarObject(L, 2);
                LuaHelper.AddListener(arg0, arg1);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(DelegateHelper.IntDelegate), typeof(object)))
            {
                DelegateHelper.IntDelegate arg0 = null;
                LuaTypes funcType1 = LuaDLL.lua_type(L, 1);

                if (funcType1 != LuaTypes.LUA_TFUNCTION)
                {
                    arg0 = (DelegateHelper.IntDelegate)ToLua.ToObject(L, 1);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 1);
                    arg0 = DelegateFactory.CreateDelegate(typeof(DelegateHelper.IntDelegate), func) as DelegateHelper.IntDelegate;
                }

                object arg1 = ToLua.ToVarObject(L, 2);
                LuaHelper.AddListener(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaHelper.AddListener"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }