using System; using eEventName = System.String; namespace GameLogic { public class GlobalEvent : GameEvent { /// /// The _inst. /// private static GlobalEvent _inst = new GlobalEvent(); public static GlobalEvent inst { get { return _inst; } } /// /// Adds the event. /// public static void add(string type, GameEventHandler handler, bool isUseOnce = false) { inst.AddEvent(type, handler, isUseOnce); } /// /// Removes the event. /// public static void remove(string type, GameEventHandler handler) { inst.RemoveEvent(type, handler); } /// /// Removes All this type of event. /// public static void remove(string type) { inst.RemoveEvent(type); } /// /// remove all event /// public static void remove() { inst.RemoveEvent(); } /// /// Dispatch the specified type, target and args. sync type. /// public static void dispatch(string type, params object[] args) { inst.DispatchEvent(type, args); } /// /// Dispatch the specified type, target and args. async type, in idle frame execute function /// public static void dispatchAsync(string type, params object[] args) { inst.DispatchAsyncEvent(type, args); } /// /// /// /// /// public static bool hasEvent(string type) { return inst.HasEvent(type); } /// /// 消息循环 /// public static void updateEvent() { inst.UpdateEvent(); } /// /// Lua需要调用 /// public static void AddLuaEvent(eEventName eName, GameEventHandler handler) { if (handler == null) { Util.LogError("AddLuaEvent Failed! Invalid Handler"); return; } inst.AddEvent(eName, handler, false); } public static void RemoveLuaEvent(eEventName eName, GameEventHandler handler) { inst.RemoveEvent(eName, handler); } public static void DispatchLuaEvent(eEventName eName, params object[] args) { inst.DispatchEvent(eName, args); } } }