Пример #1
0
 // unsubscribe from multiple tags
 public void Unsubscribe(string[] tags, Enterable script)
 {
     foreach (string tag in tags)
     {
         Unsubscribe(tag, script);
     }
 }
Пример #2
0
    // subscribe the listener to a given tag
    public void Subscribe(string tag, Enterable script)
    {
        // creating a new list of subscribers if necessary
        if (!subscribers.ContainsKey(tag))
        {
            subscribers[tag]   = new List <Enterable>();
            nearbyObjects[tag] = new List <GameObject>();
        }

        // add the subscriber
        subscribers[tag].Add(script);
    }
Пример #3
0
    // unsubscribe listener from the tag
    public void Unsubscribe(string tag, Enterable script)
    {
        if (subscribers.ContainsKey(tag))
        {
            // remove subscriber from the list of subscribers
            subscribers[tag].Remove(script);

            // remove dictionary entry if no other subscribers are interested in this tag...
            if (subscribers[tag].Count == 0)
            {
                subscribers.Remove(tag);
            }
        }
    }