Exemplo n.º 1
0
    public static bool Call(ScriptGameEvent e, object[] paramaters, object[] results, ref string err)
    {
        CheckBegin();
        if (!funcs_.ContainsKey(e))
        {
            err = "ScriptGameEvent " + e.ToString() + "has no receiver!";
            return(false);
        }
        if (LanuchFunction(funcs_[e]) == false)
        {
            return(false);
        }

        List <object> lst = null;

        if (paramaters != null)
        {
            lst = new List <object>(paramaters);
            lst.Insert(0, (int)e);
        }
        else
        {
            lst = new List <object>();
            lst.Add((int)e);
        }
        bool ret = Call(lst.ToArray(), results, ref err);

        if (!CheckEnd())
        {
            err = "Lua Stk not clean~~";
            return(false);
        }
        return(ret);
    }
Exemplo n.º 2
0
    public static int RegistEvent(ILuaState lua)
    {
        int    stk = 1;
        int    e   = L.ToInteger(stk++);
        string f   = L.ToString(stk++);

        ScriptGameEvent evt = (ScriptGameEvent)e;

        funcs_.Add(evt, f);
        return(0);
    }
Exemplo n.º 3
0
    public bool ProcEvent(ScriptGameEvent sgEvent, int param = 0, int param1 = 0, int param2 = 0)
    {
        string err = "";

        object[] results = new object[] { false };

        GameScript.Call(sgEvent, new object[] { param, param1, param2 }, results, ref err);
        if (!string.IsNullOrEmpty(err))
        {
            ClientLog.Instance.LogWarning(err);
            return(false);
        }
        return((bool)results[0]);
    }