public void TriggerEvent(Event _event)
 {
     if (subscriptions.ContainsKey(_event))
     {
         int numLoops = subscriptions[_event].Count;
         for (int i = 0; i < numLoops; i++)
         {
             IEventSubscriber s = subscriptions[_event][i];
             MonoBehaviour    m = s as MonoBehaviour;
             if (s != null && m != null)
             {
                 s.InformOfEvent(_event);
             }
             else
             {
                 subscriptions[_event].RemoveAt(i);
             }
         }
     }
 }
Example #2
0
    public void TriggerEvent(Event _event)
    {
        if (subscriptions.ContainsKey(_event))
        {
            int numLoops = subscriptions[_event].Count;
            for (int i = 0; i < numLoops; i++)
            {
                IEventSubscriber s            = subscriptions[_event][i];
                bool             isEventValid = true;
                if (s != null)
                {
                    MonoBehaviour m = s as MonoBehaviour;

                    if (s != null && m != null)
                    {
                        s.InformOfEvent(_event);
                    }
                    else
                    {
                        isEventValid = false;
                    }
                }
                else
                {
                    isEventValid = false;
                }

                if (!isEventValid)
                {
                    subscriptions[_event].RemoveAt(i);

                    i--;
                    numLoops--;
                }
            }
        }
    }