/// <summary> /// 派发一个事件 /// </summary> /// <param name="evt">该事件实例</param> /// <returns>返回派发是否成功,若返回false则表示没有该事件对应的侦听器</returns> public bool DispatchEvent(Event evt) { if (evt == null) { throw (new Exception("event is null")); }else { if (HasEventListener(evt.Type)) { if (evt.target == null) evt.target = this; evt.currentTarget = this; List<Listener> list; listener_dictionary.TryGetValue(evt.Type, out list); int count = list.Count; for (int i = 0; i < count; ++i) { list[i].listener.Invoke(evt); } return true; }else { return false; } } }