Пример #1
0
        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);
            }
        }
Пример #2
0
    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);
        }
    }
Пример #3
0
    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);
        }
    }