Esempio n. 1
0
        //----------------------------------------------------------------------------
        protected virtual bool DispatchMsg_Up(int msgId, MsgDispatchDir direction = MsgDispatchDir.MDD_Down)
        {
            bool bResult = false;

            if (m_pParentPipe != null)
            {
                bResult = m_pParentPipe.ProcessMsg(msgId, direction, this);
            }
            return(bResult);
        }
Esempio n. 2
0
        //----------------------------------------------------------------------------
        protected bool SwitchMsgUp2Down(int msgId, ref MsgDispatchDir direction, IMsgPipe fromWhere)
        {
            if (direction != MsgDispatchDir.MDD_UP || !m_bSwitchMsgUp2Down)
            {
                return(false);
            }
            bool bResult = false;

            direction = MsgDispatchDir.MDD_Down;
            bResult   = DispatchMsg_Down(msgId, direction, fromWhere);
            direction = MsgDispatchDir.MDD_UP;
            return(bResult);
        }
Esempio n. 3
0
        //----------------------------------------------------------------------------
        virtual public bool ProcessMsg <T>(int msgId, T arg, MsgDispatchDir direction = MsgDispatchDir.MDD_Down, IMsgPipe fromWhere = null)
        {
            bool bResult = false;

            //处理消息
            bResult = ExecuteMsg(msgId, arg);
            //上转下
            if (!bResult)
            {
                bResult = SwitchMsgUp2Down(msgId, arg, ref direction, fromWhere);
            }
            //分发
            if (!bResult)
            {
                bResult = DispatchMsg(msgId, arg, direction);
            }
            return(bResult);
        }
Esempio n. 4
0
        //----------------------------------------------------------------------------
        protected bool DispatchMsg(int msgId, MsgDispatchDir direction = MsgDispatchDir.MDD_Down)
        {
            bool bResult = false;

            if (direction == MsgDispatchDir.MDD_UP)
            {
                DispatchMsg_Up(msgId, direction);
            }
            else if (direction == MsgDispatchDir.MDD_Down)
            {
                DispatchMsg_Down(msgId, direction);
            }
            else
            {
                Debug.LogError("Direction Error");
            }
            return(bResult);
        }
Esempio n. 5
0
        //----------------------------------------------------------------------------
        protected virtual bool DispatchMsg_Down <T>(int msgId, T arg, MsgDispatchDir direction, IMsgPipe except = null)
        {
            bool bResult = false;

            if (m_listChildPipe == null)
            {
                return(bResult);
            }
            for (int i = 0; i < m_listChildPipe.Count; i++)
            {
                if (m_listChildPipe[i] != except)
                {
                    bResult = m_listChildPipe[i].ProcessMsg(msgId, arg, direction, this);
                    if (bResult)
                    {
                        break;
                    }
                }
            }
            return(bResult);
        }