Example #1
0
 //----------------------------------------------------------------------------
 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);
 }
Example #2
0
        //----------------------------------------------------------------------------
        protected bool ExecuteMsg(IMsg msg)
        {
            bool bResult = FindAndExecute(msg);

            SetDoEventReturnFlag(true);
            return(bResult);
        }
Example #3
0
        //----------------------------------------------------------------------------
        protected virtual bool DispatchMsg_Up(IMsg msg)
        {
            bool bResult = false;

            if (m_pParentPipe != null)
            {
                bResult = m_pParentPipe.ProcessMsg(msg, this);
            }
            return(bResult);
        }
Example #4
0
        //----------------------------------------------------------------------------
        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);
        }
Example #5
0
        //----------------------------------------------------------------------------
        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);
        }
Example #6
0
        //----------------------------------------------------------------------------
        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);
        }
Example #7
0
        //----------------------------------------------------------------------------
        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);
        }
Example #8
0
        //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);
        }
Example #9
0
        //----------------------------------------------------------------------------
        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);
        }