//发出一个事件 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); }
//发出一个事件 public static void sendEvent(GEvent e) { //如果存在这个事件 if (dict.ContainsKey(e.type)) { List <EventCallback> list = (dict[e.type] as List <EventCallback>).ToList(); callback fn = null; for (int i = 0; i < list.Count; i++) { fn = list[i].cb; e.param = list[i].param; if (fn != null) { fn(e); } } } e.release(); e = null; }
//发出一个事件 public virtual void dispatchEvent(GEvent e) { //如果存在这个事件 if (dict != null && dict.ContainsKey(e.type)) { e.eventTarget = this; List <EventCallback> list = (dict[e.type] as List <EventCallback>).ToList(); callback fn = null; for (int i = 0; i < list.Count; i++) { fn = list[i].cb; e.param = list[i].param; if (fn != null) { fn(e); } } list.Clear(); list = null; } e.release(); e = null; }