Beispiel #1
0
 public static void Register(TheEventType theType, Action<object[]> callBack)
 {
     if (!eventDicWithParam.ContainsKey(theType))
         eventDicWithParam.Add(theType, new List<Action<object[]>>());
     if (!eventDicWithParam[theType].Contains(callBack))
     {
         eventDicWithParam[theType].Add(callBack);
     }
 }
Beispiel #2
0
    public static void Register(TheEventType theType, Action callBack)
    {
        if (!eventDic.ContainsKey(theType))
            eventDic.Add(theType, new List<Action>());

        if (!eventDic[theType].Contains(callBack))
        {
            eventDic[theType].Add(callBack);
        }
    }
Beispiel #3
0
    public static void Broadcast(TheEventType type)
    {
        if (eventDic.ContainsKey(type))
        {
            List<Action> theCallBackList = eventDic[type];

            for(int i = 0; i < theCallBackList.Count; i++)
            {
                theCallBackList[i]();
            }
        }
    }
Beispiel #4
0
 /// <summary>
 /// 移除带参数的消息
 /// </summary>
 /// <param name="theType"></param>
 /// <param name="callBack"></param>
 public static void Remove(TheEventType theType, Action<object[]> callBack)
 {
     if (eventDicWithParam.ContainsKey(theType))
     {
         List<Action<object[]>> theTypeList = eventDicWithParam[theType];
         if (theTypeList.Contains(callBack))
         {
             theTypeList.Remove(callBack);
         }
         if (theTypeList.Count == 0)
             eventDicWithParam.Remove(theType);
     }
 }
Beispiel #5
0
 /// <summary>
 /// 移除不带参数的消息
 /// </summary>
 /// <param name="theType"></param>
 /// <param name="callBack"></param>
 public static void Remove(TheEventType theType, Action callBack)
 {
     if (eventDic.ContainsKey(theType))
     {
         List<Action> theTypeList = eventDic[theType];
         if (theTypeList.Contains(callBack))
         {
             theTypeList.Remove(callBack);
         }
         if (theTypeList.Count == 0)
             eventDic.Remove(theType);
     }    
 }
Beispiel #6
0
    /// <summary>
    /// d
    /// </summary>
    /// <param name="type"></param>
    public static void Broadcast(TheEventType type ,params object[] param)
    {
        if (eventDicWithParam.ContainsKey(type))
        {
            List<Action<object[]>> theCallBackList = eventDicWithParam[type];

            for (int i = 0; i < theCallBackList.Count; i++)
            {
                theCallBackList[i](param);
            }

        }
        if (eventDic.ContainsKey(type))
        {
            List<Action> theCallBackList = eventDic[type];

            for (int i = 0; i < theCallBackList.Count; i++)
            {
                theCallBackList[i]();
            }
        }
    }