// Trigger an event with a given key public static void Broadcast(string eventName, int x, int y) { HexClickedEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(x, y); } }
// Remove a listener... probably won't be used public static void StopListening(string eventName, UnityAction <int, int> listener) { if (eventManager == null) { return; } HexClickedEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
// Set up a listener for an Event name // If the event doesn't exist yet, create it public static void Listen(string eventName, UnityAction <int, int> listener) { HexClickedEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new HexClickedEvent(); thisEvent.AddListener(listener); instance.eventDictionary.Add(eventName, thisEvent); } }