Example #1
0
 /// <summary>
 /// 反注册事件
 /// </summary>
 public static void AntiRegisterHooks(NDEventType evt, EventHook evf)
 {
     if (evf == null)
     {
         return;
     }
     CheckValid();
     if (m_EventHook.ContainsKey(evt))
     {
         List <EventHook> l = m_EventHook[evt];
         if (l == null || l.Count == 0)
         {
             m_EventHook.Remove(evt);
             return;
         }
         if (l.Contains(evf))
         {
             l.Remove(evf);
         }
         if (l.Count == 0)
         {
             m_EventHook.Remove(evt);
         }
     }
 }
Example #2
0
 /// <summary>
 /// 注册事件
 /// </summary>
 public static void RegisterHooks(NDEventType evt, EventHook evf)
 {
     if (evf == null)
     {
         return;
     }
     CheckValid();
     if (m_EventHook.ContainsKey(evt))
     {
         List <EventHook> l = m_EventHook[evt];
         l.Add(evf);
     }
     else
     {
         List <EventHook> l = new List <EventHook>();
         l.Add(evf);
         m_EventHook.Add(evt, l);
     }
 }
Example #3
0
 public static void DoEvent(NDEventType evt,
                            int SceneID,
                            object Param)
 {
     CheckValid();
     if (m_EventHook.ContainsKey(evt))
     {
         List <EventHook> l = m_EventHook[evt];
         if (l == null || l.Count == 0)
         {
             return;
         }
         //foreach(EventHook f in l)
         for (int i = 0; i < l.Count; i++)
         {
             EventHook f = l[i];
             if (f != null)
             {
                 f(SceneID, Param);
             }
         }
     }
 }