예제 #1
0
        //------------------------------------------------------------

        #region Receive 先用公用消息

//         private void OnReceive(byte[] buffer, int size, IPEndPoint remotePoint)
//         {
//             FSPDataS2C data = PBSerializer.NDeserialize<FSPDataS2C>(buffer);
//
//             if (m_RecvListener != null)
//             {
//                 for (int i = 0; i < data.frames.Count; i++)
//                 {
//                     m_RecvListener(data.frames[i]);
//                 }
//
//             }
//         }

        #endregion


        //------------------------------------------------------------

        #region Send

        public bool SendFSP(int vkey, int arg, int clientFrameId)
        {
            if (m_IsRunning)
            {
                FSPVKey cmd = m_TempSendData.Vkeys[0];
                cmd.Vkey = vkey;
                cmd.Args.Add(arg);
                cmd.PlayerIdOrClientFrameId = (uint)clientFrameId;
                SessionComponent.Instance.Session.Send(m_TempSendData);
                return(true);
            }
            return(false);
        }
예제 #2
0
        /// <summary>
        /// 用于本地兼容,比如打PVE的时候,也可以用帧同步兼容
        /// </summary>
        /// <param name="vkey"></param>
        /// <param name="arg"></param>
        private void SendFSPLocal(int vkey, int arg = 0)
        {
            int nextFrameId = m_CurrentFrameIndex + 1;

            if (m_NextLocalFrame == null || m_NextLocalFrame.FrameId != nextFrameId)
            {
                m_NextLocalFrame         = new FSPFrame();
                m_NextLocalFrame.FrameId = nextFrameId;
                m_FrameBuffer.Add(m_NextLocalFrame.FrameId, m_NextLocalFrame);
            }

            FSPVKey cmd = new FSPVKey();

            cmd.Vkey = vkey;
            cmd.Args.Add(arg);
            cmd.PlayerIdOrClientFrameId = m_MinePlayerId;

            m_NextLocalFrame.Vkeys.Add(cmd);
        }
예제 #3
0
        /// <summary>
        /// 执行每一帧
        /// </summary>
        /// <param name="frameId"></param>
        /// <param name="frame"></param>
        private void ExecuteFrame(int frameId, FSPFrame frame)
        {
            //优先处理流程VKey
            if (frame != null && frame.Vkeys != null)
            {
                for (int i = 0; i < frame.Vkeys.Count; i++)
                {
                    FSPVKey cmd = frame.Vkeys[i];

                    if (cmd.Vkey == FSPVKeyBase.GAME_BEGIN)
                    {
                        Handle_GameBegin(cmd.Args[0]);
                    }
                    else if (cmd.Vkey == FSPVKeyBase.ROUND_BEGIN)
                    {
                        Handle_RoundBegin(cmd.Args[0]);
                    }
                    else if (cmd.Vkey == FSPVKeyBase.CONTROL_START)
                    {
                        Handle_ControlStart(cmd.Args[0]);
                    }
                    else if (cmd.Vkey == FSPVKeyBase.ROUND_END)
                    {
                        Handle_RoundEnd(cmd.Args[0]);
                    }
                    else if (cmd.Vkey == FSPVKeyBase.GAME_END)
                    {
                        Handle_GameEnd(cmd.Args[0]);
                    }
                    else if (cmd.Vkey == FSPVKeyBase.GAME_EXIT)
                    {
                        Handle_GameExit(cmd.PlayerIdOrClientFrameId);
                    }
                }
            }

            //再将其它VKey抛给外界处理
            if (m_FrameListener != null)
            {
                m_FrameListener(frameId, frame);
            }
        }