public static void TriggerEvent(string eventName, GameEventArgs args) { UnityGameEvent thisEvent = null; if (_eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(args); } }
public static void RemoveListener(string eventName, UnityAction <GameEventArgs> listener) { UnityGameEvent thisEvent = null; if (_eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static void Detach(string eventName, UnityAction <GameMessage> listener) { if (Instance == null) { return; } UnityGameEvent thisEvent = null; if (Instance.attachmentsDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static void StopListening(string eventName, UnityAction <GameMessage> listener) { if (eventManager == null) { return; } UnityGameEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static void AddListener(string eventName, UnityAction <GameEventArgs> listener) { UnityGameEvent thisEvent = null; if (_eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new UnityGameEvent(); thisEvent.AddListener(listener); _eventDictionary.Add(eventName, thisEvent); } }
public static void StartListening(string eventName, UnityAction <GameMessage> listener) { UnityGameEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new UnityGameEvent(); thisEvent.AddListener(listener); instance.eventDictionary.Add(eventName, thisEvent); } }
public static void TriggerEvent(string eventName, GameMessage message) { if (Instance == null) { return; } List <string> ignoreList = new List <string>(); if (Instance.enableDebugging == true) { //ignoreList.Add(EventName.System.Sheep.Roam()); ignoreList.Add(EventName.Input.Player.Move()); ignoreList.Add(EventName.System.Economy.PortalProgress()); } UnityGameEvent thisEvent = null; if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { if (Instance.enableDebugging == true) { if (!ignoreList.Contains(eventName)) { Debug.LogWarning("M:" + eventName + ": " + DebugHelper.PrintGameMessage(message)); } } thisEvent.Invoke(message); /* try { * thisEvent.Invoke(message); * } catch { * Debug.LogError("EventCoordinator event.Invoke failed: " + eventName + " <with message>: " + DebugHelper.PrintGameMessage(message)); * } */ } if (Instance.attachmentsDictionary.TryGetValue(eventName, out thisEvent)) { /* if (Instance.enableDebugging == true){ * if(!ignoreList.Contains(eventName)) * Debug.LogWarning("A:"+eventName + ": " + message); * } */ thisEvent.Invoke(message); /* try { * thisEvent.Invoke(message); * } catch { * Debug.LogError("EventCoordinator attachment.Invoke failed: " + eventName + " <with message>: " + DebugHelper.PrintGameMessage(message)); * } */ } }
public static void Attach(string eventName, UnityAction <GameMessage> eventToAttach) { //use this to attach events to other events, this way making ordered event chains //??? or use stateMachines??? UnityGameEvent thisEvent = null; if (Instance.attachmentsDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(eventToAttach); } else { thisEvent = new UnityGameEvent(); thisEvent.AddListener(eventToAttach); Instance.attachmentsDictionary.Add(eventName, thisEvent); } }
public static void TriggerEvent(string eventName, GameMessage message) { if (instance.enableDebugging == true) { Debug.LogWarning(eventName + ": " + message); } UnityGameEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(message); } if (instance.attachmentsDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(message); } }
public static void TriggerEvent(string eventName, GameMessage message) { if (Instance == null) { return; } UnityGameEvent thisEvent = null; if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { if (Instance.enableDebugging == true) { if (!Instance.ignoreEvents.list.Contains(eventName)) { //Debug.LogWarning("M:" + eventName + ": " + DebugHelper.PrintGameMessage(message)); Debug.LogWarning("M:" + eventName + ": " + message); } } thisEvent.Invoke(message); /* try { * thisEvent.Invoke(message); * } catch { * Debug.LogError("EventCoordinator event.Invoke failed: " + eventName + " <with message>: " + DebugHelper.PrintGameMessage(message)); * } */ } if (Instance.attachmentsDictionary.TryGetValue(eventName, out thisEvent)) { if (Instance.showAttachedEvents && Instance.enableDebugging) { if (!Instance.ignoreAttachedEvents.list.Contains(eventName)) { Debug.LogWarning("M:" + eventName + ": " + message); } } thisEvent.Invoke(message); /* try { * thisEvent.Invoke(message); * } catch { * Debug.LogError("EventCoordinator attachment.Invoke failed: " + eventName + " <with message>: " + DebugHelper.PrintGameMessage(message)); * } */ } }
public static bool HasEvent(string eventName, UnityAction <GameMessage> listener) { UnityGameEvent thisEvent = null; if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { Debug.Log(thisEvent.GetPersistentEventCount()); for (int i = 0; i < thisEvent.GetPersistentEventCount(); i++) { Debug.Log(thisEvent.GetPersistentMethodName(i) + " :eventMethodName. evnt mng listner:" + listener.GetType().Name); if (thisEvent.GetPersistentMethodName(i) == listener.GetType().Name) { return(true); } } return(false); } else { return(false); } }
public static void TriggerEvent(string eventName, GameMessage message) { if (Instance == null) { return; } if (Instance.enableDebugging == true) { //ignoreList.Add(EventName.System.Sheep.Roam()); //ignoreList.Add(EventName.System.Economy.EatGrass()); //ignoreList.Add(EventName.System.Player.PlayerCardsSorted()); //ignoreList.Add(EventName.System.Player.ProfileUpdate()); //ignoreList.Add(EventName.System.BaseTargetUpdate()); } UnityGameEvent thisEvent = null; if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { if (Instance.enableDebugging == true) { if (!Instance.debugIgnoreList.Contains(eventName)) { Debug.LogWarning("M:" + eventName + ": " + DebugHelper.PrintGameMessage(message)); } } thisEvent.Invoke(message); } if (Instance.attachmentsDictionary.TryGetValue(eventName, out thisEvent)) { /* if (Instance.enableDebugging == true){ * if(!ignoreList.Contains(eventName)) * Debug.LogWarning("A:"+eventName + ": " + message); * } */ thisEvent.Invoke(message); } }