Esempio n. 1
0
 void CallMethod(KeyCode key, bool bDown)
 {
     if (!SLua.LuaSvr.inited || null == SLua.LuaSvr.mainState)
     {
         return;
     }
     SLua.LuaState    l    = SLua.LuaSvr.mainState;
     SLua.LuaFunction func = l.getFunction("OnHotKeyInput");
     if (null != func)
     {
         func.call(key, bDown);
         func.Dispose();
     }
 }
Esempio n. 2
0
 static bool ReportLog(LogType type, string str)
 {
     if (!SLua.LuaSvr.inited || null == SLua.LuaSvr.mainState)
     {
         return(false);
     }
     SLua.LuaState l = SLua.LuaSvr.mainState;
     if (null == l)
     {
         return(false);
     }
     SLua.LuaFunction func = l.getFunction("OnUnityLog");
     if (null != func)
     {
         func.call(new object[] { type, str });
         func.Dispose();
         return(true);
     }
     return(false);
 }
Esempio n. 3
0
    void InitKeyCodeMap()
    {
        if (bInited)
        {
            return;
        }

        if (null == LuaSvr.main || !LuaSvr.main.inited || null == LuaSvr.main.luaState)
        {
            return;
        }
        SLua.LuaState l = SLua.LuaSvr.main.luaState;
        if (null == l)
        {
            return;
        }
        bInited = true;
        SLua.LuaFunction func = l.getFunction("OnHotKeyCodeMap");
        if (null != func)
        {
            LuaTable ret = func.call() as LuaTable;
            foreach (var obj in ret)
            {
                object  value = obj.value;
                int     ival  = Convert.ToInt32(value);
                KeyCode key   = (KeyCode)Enum.ToObject(typeof(KeyCode), ival);

                if (!sKeyCodeMap.ContainsKey(key))
                {
                    sKeyCodeMap.Add(key, true);
                }
                else
                {
                    sKeyCodeMap[key] = true;
                }
            }

            func.Dispose();
        }
    }
Esempio n. 4
0
        public void init()
        {
#if LuaDebugger
            try
            {
                IPEndPoint localEP = new IPEndPoint(IPAddress.Parse(DebugIP), DebugPort);
                server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
                server.Bind(localEP);
                server.Listen(10);
                server.BeginAccept(new AsyncCallback(onClientConnect), server);
                Logger.Log("Opened lua debugger interface at " + localEP.ToString());

                // redirect output to client socket
                var luaFunc = state.getFunction("Slua.ldb.setOutput");
                luaFunc.call((LuaCSFunction)output);
            }
            catch (Exception e)
            {
                Logger.LogError(string.Format("LuaDebugger listened failed for reason::{0}", e.Message));
            }
#endif
        }