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

            if (count == 1)
            {
                string arg0 = ToLua.CheckString(L, 1);
                UserEventManager.TriggerEvent(arg0);
                return(0);
            }
            else if (count == 2)
            {
                string arg0 = ToLua.CheckString(L, 1);
                object arg1 = ToLua.ToVarObject(L, 2);
                UserEventManager.TriggerEvent(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UserEventManager.TriggerEvent"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 2
0
 public static void EnterGame()
 {
     //加载TableUI
     UIManager.OpenUI("Prefabs/TableUI", UIManager.Instance.BaseUIRoot, (GameObject obj) =>
     {
         UserEventManager.TriggerEvent("LoginGame");
         Debug.Log("CommonMethod.EnterGame Open TableUI Success!");
     });
 }
Exemplo n.º 3
0
    private void receiveData(byte[] data)
    {
        root_proto proto = new root_proto();

        proto = Deserialize(root_proto.Parser, data) as root_proto;
        Debug.Log("Client.receiveData messageName = " + proto.MessageName);
        //校正服务器时间
        Function.SetServerTime((long)proto.ServerTime);
        //数据
        byte[] byteData = proto.MessageData.ToByteArray();
        //取消菊花
        if (0 != proto.MessageID && true == RequestLoadDict[proto.MessageID])
        {
            //0是推送协议
            LoadLayerManager.Instance.RemoveLoad();
        }
        RequestLoadDict.Remove(proto.MessageID);

        //事件
        UserEventManager.TriggerEvent(proto.MessageName, byteData);

        //激活回调函数
        if (CallbackDict.ContainsKey(proto.MessageID))
        {
            try
            {
                RequestCallback callback = CallbackDict[proto.MessageID];
                if (null != callback)
                {
                    callback(byteData);
                }
                CallbackDict.Remove(proto.MessageID);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }
    }