static int AddFrameDelegateToTimeCalc(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 4);
            TimeHelper obj  = (TimeHelper)ToLua.CheckObject(L, 1, typeof(TimeHelper));
            string     arg0 = ToLua.CheckString(L, 2);
            float      arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
            DelegateHelper.FloatDelegate arg2 = null;
            LuaTypes funcType4 = LuaDLL.lua_type(L, 4);

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

            bool o = obj.AddFrameDelegateToTimeCalc(arg0, arg1, arg2);
            LuaDLL.lua_pushboolean(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
示例#2
0
    /// <summary>
    /// Add time calc dictionary item, delegate execute every frame.
    /// </summary>
    /// <param name="key">item key</param>
    /// <param name="duration">time over duration</param>
    /// <param name="l_timeCalcIntDelegate">delegate</param>
    /// <returns>is add succeed</returns>
    public bool AddFrameDelegateToTimeCalc(string key, float duration, DelegateHelper.FloatDelegate l_floatDelegate = 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_TimeCalcFloatDelegate = l_floatDelegate, DelegateMode = 4
        });

        StartCalc(key);
        return(true);
    }
示例#3
0
 public static void AddListener(DelegateHelper.FloatDelegate source, object dest)
 {
     source += (DelegateHelper.FloatDelegate)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));
        }
    }