private void SendNotifyToObject(NotifyParam notify) { if (dispatchList.ContainsKey(notify.key)) { Dictionary <Action <NotifyParam>, uGaMaBehaviour> actions = dispatchList[notify.key]; for (int i = 0; i < actions.Count; i++) { uGaMaBehaviour tmpBehavior = actions.Values.ElementAt(i); tmpBehavior.OnHandlerNotify(notify, actions.Keys.ElementAt(i)); } } }
public void RemoveListener(uGaMaBehaviour obj, object dispatchKey, Action <NotifyParam> callback) { if (dispatchList.ContainsKey(dispatchKey)) { Dictionary <Action <NotifyParam>, uGaMaBehaviour> actions = dispatchList[dispatchKey]; for (int i = 0; i < actions.Count; i++) { if (actions.Keys.ElementAt(i) == callback && actions.Values.ElementAt(i) == obj) { actions.Remove(actions.Keys.ElementAt(i)); } } } }
public void AddListener(uGaMaBehaviour obj, object dispatchKey, Action <NotifyParam> callback) { if (!dispatchList.ContainsKey(dispatchKey)) { Dictionary <Action <NotifyParam>, uGaMaBehaviour> actions = new Dictionary <Action <NotifyParam>, uGaMaBehaviour>(); actions.Add(callback, obj); dispatchList.Add(dispatchKey, actions); } else { Dictionary <Action <NotifyParam>, uGaMaBehaviour> actions = dispatchList[dispatchKey]; actions.Add(callback, obj); } }
public void RemoveListener(uGaMaBehaviour obj, object dispatchKey, Action<NotifyParam> callback) { if(dispatchList.ContainsKey(dispatchKey)) { Dictionary<Action<NotifyParam>, uGaMaBehaviour> actions = dispatchList[dispatchKey]; for (int i = 0; i < actions.Count; i++) { if(actions.Keys.ElementAt(i) == callback && actions.Values.ElementAt(i) == obj) { actions.Remove(actions.Keys.ElementAt(i)); } } } }
public void AddListener(uGaMaBehaviour obj, object dispatchKey, Action<NotifyParam> callback) { if(!dispatchList.ContainsKey(dispatchKey)) { Dictionary<Action<NotifyParam>, uGaMaBehaviour> actions = new Dictionary<Action<NotifyParam>, uGaMaBehaviour>(); actions.Add(callback, obj); dispatchList.Add(dispatchKey, actions); } else { Dictionary<Action<NotifyParam>, uGaMaBehaviour> actions = dispatchList[dispatchKey]; actions.Add(callback, obj); } }
public void RemoveAllListeners(uGaMaBehaviour obj) { foreach (KeyValuePair <object, Dictionary <Action <NotifyParam>, uGaMaBehaviour> > item in dispatchList) { Dictionary <Action <NotifyParam>, uGaMaBehaviour> actions = item.Value; if (actions.ContainsValue(obj)) { for (int i = 0; i < actions.Count; i++) { if (actions.Values.ElementAt(i) == obj) { actions.Remove(actions.Keys.ElementAt(i)); } } } } }
public void RemoveAllListeners(uGaMaBehaviour obj) { foreach (KeyValuePair<object, Dictionary<Action<NotifyParam>, uGaMaBehaviour>> item in dispatchList) { Dictionary<Action<NotifyParam>, uGaMaBehaviour> actions = item.Value; if(actions.ContainsValue(obj)) { for (int i = 0; i < actions.Count; i++) { if(actions.Values.ElementAt(i) == obj) { actions.Remove(actions.Keys.ElementAt(i)); } } } } }