Esempio n. 1
0
    static int RegesterListener(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        string arg0 = LuaScriptMgr.GetLuaString(L, 1);

        UtilCommon.EventHandle arg1 = null;
        LuaTypes funcType2          = LuaDLL.lua_type(L, 2);

        if (funcType2 != LuaTypes.LUA_TFUNCTION)
        {
            arg1 = (UtilCommon.EventHandle)LuaScriptMgr.GetNetObject(L, 2, typeof(UtilCommon.EventHandle));
        }
        else
        {
            LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 2);
            arg1 = (param0) =>
            {
                int top = func.BeginPCall();
                LuaScriptMgr.PushVarObject(L, param0);
                func.PCall(top, 1);
                func.EndPCall(top);
            };
        }

        string arg2 = LuaScriptMgr.GetLuaString(L, 3);

        ioo.RegesterListener(arg0, arg1, arg2);
        return(0);
    }
Esempio n. 2
0
    static int EventHandle(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        LuaFunction arg0 = LuaScriptMgr.GetLuaFunction(L, 1);

        UtilCommon.EventHandle o = LuaHelper.EventHandle(arg0);
        LuaScriptMgr.Push(L, o);
        return(1);
    }
Esempio n. 3
0
 public static Delegate UtilCommon_EventHandle(LuaFunction func)
 {
     UtilCommon.EventHandle d = (param0) =>
     {
         int    top = func.BeginPCall();
         IntPtr L   = func.GetLuaState();
         LuaScriptMgr.PushVarObject(L, param0);
         func.PCall(top, 1);
         func.EndPCall(top);
     };
     return(d);
 }
Esempio n. 4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="_type"></param>
    /// <param name="_handle"></param>
    public void RegesterListener(string _type, UtilCommon.EventHandle _handle, string _guid)
    {
        if (!m_eventDict.ContainsKey(_type))
        {
            m_eventDict.Add(_type, new Dictionary <string, UtilCommon.EventHandle>());
        }

        if (!HasRegestered(_type, _guid))
        {
            m_eventDict[_type].Add(_guid, _handle);
        }
    }
Esempio n. 5
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="_type"></param>
    /// <param name="_playerID"></param>
    /// <param name="_value"></param>
    public void TriggerListener(string _type, object _data)
    {
        if (null == m_eventDict || !m_eventDict.ContainsKey(_type))
        {
            return;
        }

        Dictionary <string, UtilCommon.EventHandle> dict = m_eventDict[_type];

        List <UtilCommon.EventHandle> list = new List <UtilCommon.EventHandle>(dict.Values);

        for (int i = 0; i < dict.Count; ++i)
        {
            UtilCommon.EventHandle handle = list[i];
            if (null != handle)
            {
                handle(_data);
            }
        }
    }
Esempio n. 6
0
 public static void RegesterListener(string type, UtilCommon.EventHandle eventHandle, string guid)
 {
     EventLuaHelper.Instance.RegesterListener(type, eventHandle, guid);
 }