//---------------------------------------------------------------------------- protected bool FindAndExecute(IMsg msg) { if (m_dictMsgFunc == null) { return(false); } if (m_dictMsgFunc.ContainsKey(msg.m_nMsgID)) { if (msg.m_TypeCount == MsgParamCount.one) { m_dictMsgFunc[msg.m_nMsgID].Invoke(this, new object[] { msg.m_objOne }); } else if (msg.m_TypeCount == MsgParamCount.two) { m_dictMsgFunc[msg.m_nMsgID].Invoke(this, new object[] { msg.m_objOne, msg.m_objTwo }); } else if (msg.m_TypeCount == MsgParamCount.more) { m_dictMsgFunc[msg.m_nMsgID].Invoke(this, new object[] { msg.m_objOne, msg.m_objTwo, msg.m_listObj }); } else { m_dictMsgFunc[msg.m_nMsgID].Invoke(this, null); } return(GetDoEventReturnFlag()); } return(false); }
//---------------------------------------------------------------------------- protected bool ExecuteMsg(IMsg msg) { bool bResult = FindAndExecute(msg); SetDoEventReturnFlag(true); return(bResult); }
//---------------------------------------------------------------------------- protected virtual bool DispatchMsg_Up(IMsg msg) { bool bResult = false; if (m_pParentPipe != null) { bResult = m_pParentPipe.ProcessMsg(msg, this); } return(bResult); }
//---------------------------------------------------------------------------- protected override bool DispatchMsg_Down(IMsg msg, IMsgPipe except = null) { bool bResult = false; bResult = base.DispatchMsg_Down(msg, except); if (!bResult && ReferenceEquals(_curSubState, null) && @ReferenceEquals(_curSubState, except)) { bResult = _curSubState.ProcessMsg(msg); } return(bResult); }
//---------------------------------------------------------------------------- protected override bool DispatchMsg_Up(IMsg msg) { bool bResult = false; bResult = base.DispatchMsg_Up(msg); if (!bResult && !ReferenceEquals(_parentState, null)) { bResult = _parentState.ProcessMsg(msg); } return(bResult); }
//---------------------------------------------------------------------------- protected bool SwitchMsgUp2Down(IMsg msg, IMsgPipe fromWhere) { if (msg.m_Direction != MsgDispatchDir.MDD_UP || !m_bSwitchMsgUp2Down) { return(false); } bool bResult = false; msg.m_Direction = MsgDispatchDir.MDD_Down; bResult = DispatchMsg_Down(msg, fromWhere); msg.m_Direction = MsgDispatchDir.MDD_UP; return(bResult); }
//---------------------------------------------------------------------------- protected bool DispatchMsg(IMsg msg) { bool bResult = false; if (msg.m_Direction == MsgDispatchDir.MDD_UP) { DispatchMsg_Up(msg); } else if (msg.m_Direction == MsgDispatchDir.MDD_Down) { DispatchMsg_Down(msg); } else { Debug.LogError("Direction error"); } return(bResult); }
//function //---------------------------------------------------------------------------- virtual public bool ProcessMsg(IMsg msg, IMsgPipe fromWhere = null) { bool bResult = false; //处理消息 bResult = ExecuteMsg(msg); //上转下 if (!bResult) { bResult = SwitchMsgUp2Down(msg, fromWhere); } //分发 if (!bResult) { bResult = DispatchMsg(msg); return(bResult); } return(bResult); }
//---------------------------------------------------------------------------- protected virtual bool DispatchMsg_Down(IMsg msg, IMsgPipe except = null) { bool bResult = false; if (m_listChildPipe == null) { return(bResult); } int nChildNum = m_listChildPipe.Count; for (int i = 0; i < nChildNum; i++) { if (m_listChildPipe[i] != except) { bResult = m_listChildPipe[i].ProcessMsg(msg, this); if (bResult) { break; } } } return(bResult); }