Esempio n. 1
0
        public void Add(int eventID, EventHandlerDelegate handler)
        {
            if (handler == null)
            {
                return;
            }
            if (m_Handlers == null)
            {
                m_Handlers = new Dictionary <int, List <EventHandlerDelegate> >();
            }
            List <EventHandlerDelegate> handlers = null;

            if (m_Handlers.TryGetValue(eventID, out handlers) == false)
            {
                handlers = new List <EventHandlerDelegate>();
                handlers.Add(handler);
                m_Handlers.Add(eventID, handlers);
                CrossContextEventProcessor.GetInstance().Register(eventID, handler);
            }
            else
            {
                if (handlers.Contains(handler) == false)
                {
                    handlers.Add(handler);
                    CrossContextEventProcessor.GetInstance().Register(eventID, handler);
                }
            }
        }
 /// <summary>
 /// Get a single instance of type 'CrossContextEventProcessor'
 /// </summary>
 /// <returns></returns>
 public static CrossContextEventProcessor GetInstance()
 {
     if (m_Instance == null)
     {
         m_Instance = new CrossContextEventProcessor();
     }
     return(m_Instance);
 }
Esempio n. 3
0
 public override void End()
 {
     if (mSceneObject != null)
     {
         GameObject.DestroyObject(mSceneObject);
     }
     Resources.UnloadUnusedAssets();
     CrossContextEventProcessor.GetInstance().Notify(new EventEX <GameScene>((int)CrossContextEventType.GE_SceneEnd, this));
     return;
 }
 //public GTModuleListenerControl()
 //{
 //    mGlobalEventManager = GlobalEventManager.GetSingleton();
 //    mNetMsgEventManager = NetWorkEventManager.GetSingleton();
 //}
 public GTModuleListenerControl(GTModel varModel)
 {
     mModel = varModel;
     if (varModel != null)
     {
         varModel.AddListener(this);
     }
     mGlobalMsgQueue     = new EventHandlerQueue(CrossContextEventProcessor.GetInstance());
     mNetMsgQueue        = new EventHandlerQueue(NetworkEventProcessor.GetInstance());
     mGlobalEventManager = CrossContextEventProcessor.GetInstance();
     mNetMsgEventManager = NetworkEventProcessor.GetInstance();
 }
Esempio n. 5
0
        public void Remove(int eventID, EventHandlerDelegate handler)
        {
            if (handler == null)
            {
                return;
            }
            if (m_Handlers == null || m_Handlers.Count == 0)
            {
                return;
            }
            List <EventHandlerDelegate> tmpDels = null;

            if (m_Handlers.TryGetValue(eventID, out tmpDels))
            {
                tmpDels.Clear();
                m_Handlers.Remove(eventID);
                CrossContextEventProcessor.GetInstance().Unregister(eventID, handler);
            }
        }
Esempio n. 6
0
 public void RemoveAll()
 {
     if (m_Handlers == null || m_Handlers.Count == 0)
     {
         return;
     }
     Dictionary <int, List <EventHandlerDelegate> > .Enumerator it = m_Handlers.GetEnumerator();
     for (int i = 0; i < m_Handlers.Count; i++)
     {
         it.MoveNext();
         KeyValuePair <int, List <EventHandlerDelegate> > kvp = it.Current;
         if (kvp.Value == null || kvp.Value.Count == 0)
         {
             continue;
         }
         for (int j = 0; j < kvp.Value.Count; j++)
         {
             CrossContextEventProcessor.GetInstance().Unregister(kvp.Key, kvp.Value[j]);
         }
     }
     m_Handlers.Clear();
 }
Esempio n. 7
0
 public void Initialize()
 {
     mGlobalMsgQueue = new EventHandlerQueue(CrossContextEventProcessor.GetInstance());
     mGlobalMsgQueue.Add((int)CrossContextEventType.GE_LevelWasLoaded, OnLevelLoaded);
     ReadGameSettingConfig();
 }
Esempio n. 8
0
 public override void Begin()
 {
     CrossContextEventProcessor.GetInstance().Notify(new EventEX <GameScene>((int)CrossContextEventType.GE_SceneBegin, this));
     return;
 }