public SubjectEvent Clone() { SubjectEvent e = new SubjectEvent(type, data); e.curTarget = this.curTarget; return(e); }
public bool NotifyEvent(SubjectEvent evt_) { if (m_notifier == null) { return(false); } return(m_notifier.NotifyEvent(evt_)); }
public bool NotifyEvent(SubjectEvent evt_) { if (!m_id2fun.ContainsKey(evt_.type)) { return(false); } m_id2fun[evt_.type](evt_); return(true); }
void OnMouseWheel(object evt_) { SubjectEvent evt = evt_ as SubjectEvent; float axis = -(float)evt.data; float dis = m_camera.distance; float disTo = dis + axis * Time.deltaTime * 500; m_camera.SetDistance(disTo); }
//通知事件 public bool NotifyEvent(SubjectEvent evt_) { evt_.curTarget = this; List <Observer> arr = GetObsArr(evt_.type); if (arr == null) { return(false); } bool b = InvokeEvent(evt_.type, arr, evt_); evt_.curTarget = null; return(b); }
//-------∽-★-∽------∽-★-∽--------∽-★-∽数据管理∽-★-∽--------∽-★-∽------∽-★-∽--------// void OnMouseMove(object evt_) { if (!m_mouse.IsPressed(MouseKey.MOUSE_RIGHT)) { return; } SubjectEvent evt = evt_ as SubjectEvent; Vector2 axis = (Vector2)evt.data; float axisX = m_camera.axisX; float axisY = m_camera.axisY; float axisXTo = axisX - axis.y * Time.deltaTime * 500; float axisYTo = axisY + axis.x * Time.deltaTime * 500; m_camera.SetAxisXY(axisXTo, axisYTo, true); }
public bool NotifyWithEvent(string type_, object data_ = null) { if (!m_id2fun.ContainsKey(type_)) { return(false); } //SubjectEvent evt = new SubjectEvent(type_, data_); SubjectEvent evt = __evtPool.Pop(); evt.type = type_; evt.data = data_; bool b = NotifyEvent(evt); evt.Clear(); __evtPool.Push(evt); return(b); }
static void onMainLoadEvt(object evt_) { SubjectEvent e = evt_ as SubjectEvent; switch (e.type) { case LOAD_EVT.COMPLETE: //加载完成 if (m_loadView == null) { //没有加载条, 直接完成 OnMainLoadComplete(); } break; case LOAD_EVT.VIEW_COMPLETE: OnMainLoadComplete(); break; } }
bool InvokeEvent(string type_, List <Observer> objArr_, SubjectEvent evt_) { if (objArr_.Count == 0) { return(false); } ++m_invalid; bool succ = false; bool b = false; Observer obs; int i = 0; int len = objArr_.Count; for (; i < len; ++i) { if (objArr_.Count == 0) { //$vec被内存回收 b = false; break; } obs = objArr_[i]; if (obs != null) { obs.func(evt_); succ = true; } else { //已经删除 b = true; } if (evt_.isStopped) { //停止传递 break; } } if (m_invalid > 0) { --m_invalid; } if (b) { //需要校正 Adjust(objArr_); if (objArr_.Count == 0) { RemoveObsArr(type_); } } return(succ); }
static public bool NotifyEvent(SubjectEvent evt_) { return(m_subject.NotifyEvent(evt_)); }