예제 #1
0
    static int set_OnEveryEventDispatch(IntPtr L)
    {
        try
        {
            InputEventCallBack arg0      = null;
            LuaTypes           funcType2 = LuaDLL.lua_type(L, 2);

            if (funcType2 != LuaTypes.LUA_TFUNCTION)
            {
                arg0 = (InputEventCallBack)ToLua.CheckObject(L, 2, typeof(InputEventCallBack));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                arg0 = DelegateFactory.CreateDelegate(typeof(InputEventCallBack), func) as InputEventCallBack;
            }

            InputManager.OnEveryEventDispatch = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #2
0
    static int RemoveAllEventListener(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 2);
            string             arg0      = ToLua.CheckString(L, 1);
            InputEventCallBack arg1      = null;
            LuaTypes           funcType2 = LuaDLL.lua_type(L, 2);

            if (funcType2 != LuaTypes.LUA_TFUNCTION)
            {
                arg1 = (InputEventCallBack)ToLua.CheckObject(L, 2, typeof(InputEventCallBack));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                arg1 = DelegateFactory.CreateDelegate(typeof(InputEventCallBack), func) as InputEventCallBack;
            }

            InputManager.RemoveAllEventListener(arg0, arg1);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    protected void AllEventDispatch(string eventName, IInputEventBase inputEvent)
    {
        if (m_OnAllEventDispatch != null)
        {
            Delegate[] eventArray = m_OnAllEventDispatch.GetInvocationList();

            for (int i = 0; i < eventArray.Length; i++)
            {
                try
                {
                    InputEventCallBack callBack = (InputEventCallBack)eventArray[i];
                    callBack(eventName, inputEvent);
                }
                catch (Exception e)
                {
                    Debug.LogError(e.ToString());
                }
            }
        }
    }
예제 #4
0
    public static Delegate InputEventCallBack(LuaFunction func, LuaTable self, bool flag)
    {
        if (func == null)
        {
            InputEventCallBack fn = delegate(string param0, IInputEventBase param1) { };
            return(fn);
        }

        if (!flag)
        {
            InputEventCallBack_Event target = new InputEventCallBack_Event(func);
            InputEventCallBack       d      = target.Call;
            target.method = d.Method;
            return(d);
        }
        else
        {
            InputEventCallBack_Event target = new InputEventCallBack_Event(func, self);
            InputEventCallBack       d      = target.CallWithSelf;
            target.method = d.Method;
            return(d);
        }
    }
예제 #5
0
    public static void RemoveAllEventListener(string eventName, InputEventCallBack callback)
    {
        IInputDispatcher dispatcher = GetDispatcher(eventName);

        dispatcher.m_OnAllEventDispatch -= callback;
    }