예제 #1
0
    // 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);
        }
    }
예제 #2
0
    // 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);
        }
    }
예제 #3
0
    // 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);
        }
    }