Пример #1
0
        private void RebuilddictObservers()
        {
            if (!dirty)
            {
                return;
            }

            dictObservers.Clear();
            LuaMessageObserver observer = null;

            for (int i = observers.Count - 1; i >= 0; i--)
            {
                observer = observers[i];
                if (!observer.vaild)
                {
                    observers.RemoveAt(i);
                }
                else
                {
                    if (!dictObservers.ContainsKey(observer.messageID))
                    {
                        dictObservers[observer.messageID] = new List <LuaMessageObserver>();
                    }
                    dictObservers[observer.messageID].Add(observer);
                }
            }
            this.dirty = false;
        }
Пример #2
0
        public void Regist(int messageID, object observer, LuaMessageCallback callback)
        {
            LuaMessageObserver _observer = new LuaMessageObserver();

            _observer.messageID = messageID;
            _observer.callback  = callback;
            _observer.obj       = observer;
            _observer.vaild     = true;

            observers.Add(_observer);
            dirty = true;
        }
Пример #3
0
        public void UnRegist(int messageID, object observer)
        {
            LuaMessageObserver _observer = null;

            for (int i = 0, iMax = observers.Count; i < iMax; ++i)
            {
                _observer = observers[i];
                if (_observer.messageID == messageID && _observer.obj.Equals(observer))
                {
                    _observer.vaild = false;
                }
            }
            dirty = true;
        }