Beispiel #1
0
    static int Dispatch(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <ToLuaUIFramework.BaseMsg>(L, 2))
            {
                ToLuaUIFramework.MsgEnum arg0 = (ToLuaUIFramework.MsgEnum)ToLua.CheckObject(L, 1, typeof(ToLuaUIFramework.MsgEnum));
                ToLuaUIFramework.BaseMsg arg1 = (ToLuaUIFramework.BaseMsg)ToLua.ToObject(L, 2);
                ToLuaUIFramework.MessageCenter.Dispatch(arg0, arg1);
                return(0);
            }
            else if (TypeChecker.CheckTypes <ToLuaUIFramework.MsgEnum>(L, 1) && TypeChecker.CheckParamsType <object>(L, 2, count - 1))
            {
                ToLuaUIFramework.MsgEnum arg0 = (ToLuaUIFramework.MsgEnum)ToLua.CheckObject(L, 1, typeof(ToLuaUIFramework.MsgEnum));
                object[] arg1 = ToLua.ToParamsObject(L, 2, count - 1);
                ToLuaUIFramework.MessageCenter.Dispatch(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: ToLuaUIFramework.MessageManager.Dispatch"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #2
0
 /// <summary>
 /// 触发事件
 /// </summary>
 public static void Dispatch(MsgEnum msgEnum, BaseMsg msg)
 {
     Debug.Log("触发事件: " + msgEnum);
     if (eventsBuffer.ContainsKey(msgEnum))
     {
         List <Action <BaseMsg> > callbacks = eventsBuffer[msgEnum];
         for (int i = 0; i < callbacks.Count; i++)
         {
             if (callbacks[i] != null)
             {
                 callbacks[i].Invoke(msg);
             }
         }
     }
 }