public void TriggerEvent(GameGlobeVar.EventId eventId) { Delegate del = null; if (_dicEvents.TryGetValue((int)eventId, out del)) { if (null == del) { return; } Delegate[] invocationList = del.GetInvocationList(); for (int i = 0; i < invocationList.Length; ++i) { Action action = invocationList[i] as Action; if (null == action) { LogModule.LogError(string.Format("## Trigger Event {0} Parameters type [void] are not match target type : {1}.", eventId.ToString(), invocationList[i].GetType())); return; } action(); } } }
public void TriggerEvent <T0, T1, T2>(GameGlobeVar.EventId eventId, T0 p0, T1 p1, T2 p2) { Delegate del = null; if (_dicEvents.TryGetValue((int)eventId, out del)) { if (null == del) { return; } Delegate[] invocationList = del.GetInvocationList(); for (int i = 0; i < invocationList.Length; ++i) { Action <T0, T1, T2> action = invocationList[i] as Action <T0, T1, T2>; if (null == action) { LogModule.LogError(string.Format("## Trigger Event {0} Parameters type [{1}, {2}, {3}] are not match target type : {4}.", eventId.ToString(), p0.GetType(), p1.GetType(), p2.GetType(), invocationList[i].GetType())); return; } action(p0, p1, p2); } } }
/// <summary> /// EventLog日志输出 /// </summary> /// <param name="eventId"></param> /// <param name="handleType"></param> /// <param name="targetEventType"></param> /// <param name="listener"></param> private void LogTypeError(GameGlobeVar.EventId eventId, CoreGlobeVar.HandleType handleType, Delegate targetEventType, Delegate listener) { LogModule.LogError(string.Format("Event Id {0}, [{1}] Wrong Listener Type {2}, needed Type {3}.", eventId.ToString(), CoreGlobeVar.HandleTypeDic[(int)handleType], targetEventType.GetType(), listener.GetType())); }