Ejemplo n.º 1
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];
             MonoBehaviour    m = s as MonoBehaviour;
             if (s != null && m != null)
             {
                 s.InformOfEvent(_event);
             }
             else
             {
                 subscriptions[_event].RemoveAt(i);
             }
         }
     }
 }
Ejemplo n.º 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--;
                }
            }
        }
    }