Exemplo n.º 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);
        }
    }
Exemplo n.º 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);
        }
    }
Exemplo n.º 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);
        }
    }