Exemplo n.º 1
0
 //发出一个事件
 static bool sendVoteEvent(GEvent e)
 {
     //如果存在这个事件
     if (dictvote.ContainsKey(e.type))
     {
         List <VoteCallback> list = (dictvote[e.type] as List <VoteCallback>).ToList();
         votecallback        fn   = null;
         for (int i = 0; i < list.Count; i++)
         {
             fn      = list[i].cb;
             e.param = list[i].param;
             if (fn != null)
             {
                 if (!fn(e))
                 {
                     e.release();
                     e = null;
                     return(false);
                 }
             }
         }
     }
     e.release();
     e = null;
     return(true);
 }
Exemplo n.º 2
0
 //删除一个类型的,一个指定回调
 public static void removeVote(string type, votecallback fn)
 {
     if (dictvote.ContainsKey(type))
     {
         List <VoteCallback> list = dictvote[type] as List <VoteCallback>;
         //StarEngine.Debuger.LogTrace("````````````````````````````删除了侦听:" + type);
         list.RemoveAll(x => x.cb == fn);
         if (list.Count <= 0)
         {
             dict.Remove(type);
         }
     }
 }
Exemplo n.º 3
0
    public static void addVote(string type, votecallback fn, object param = null)
    {
        //如果不存在就创建一个字典
        if (!dictvote.ContainsKey(type))
        {
            //           StarEngine.Debuger.LogTrace("````````````````````````````加入了侦听:    " + type);
            dictvote.Add(type, new List <VoteCallback>());
        }

        List <VoteCallback> list = dictvote[type] as List <VoteCallback>;

        if (list.Find(x => x.cb == fn) != null)
        {
            //          StarEngine.Debuger.LogTrace("````````````````````````````重复加入了投票侦听    " + type);
            return;
        }

        VoteCallback ecb = new VoteCallback();

        ecb.cb    = fn;
        ecb.param = param;
        dictvote[type].Add(ecb);
    }