コード例 #1
0
        private void AddServerFrame(FSPFrame frame)
        {
            if (frame.FrameId <= 0)
            {
                ExecuteFrame(frame.FrameId, frame);
                return;
            }

            frame.FrameId       = frame.FrameId * m_Param.ClientFrameRateMultiple;
            m_ClientLockedFrame = frame.FrameId + m_Param.ClientFrameRateMultiple - 1;

            m_FrameBuffer.Add(frame.FrameId, frame);
            m_FrameCtrl.AddFrameId(frame.FrameId);
        }
コード例 #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);
            }
        }
コード例 #4
0
        /// <summary>
        /// 由外界驱动
        /// </summary>
        public void EnterFrame()
        {
            if (!m_IsRunning)
            {
                return;
            }

            if (!m_Param.UseLocal)
            {
                m_Client.EnterFrame();

                int speed = m_FrameCtrl.GetFrameSpeed(m_CurrentFrameIndex);
                while (speed > 0)
                {
                    if (m_CurrentFrameIndex < m_ClientLockedFrame)
                    {
                        m_CurrentFrameIndex++;
                        FSPFrame frame = m_FrameBuffer[m_CurrentFrameIndex];
                        ExecuteFrame(m_CurrentFrameIndex, frame);
                    }

                    speed--;
                }

                //这里可能加预表现
            }
            else
            {
                if (m_ClientLockedFrame == 0 || m_CurrentFrameIndex < m_ClientLockedFrame)
                {
                    m_CurrentFrameIndex++;
                    FSPFrame frame = m_FrameBuffer[m_CurrentFrameIndex];
                    ExecuteFrame(m_CurrentFrameIndex, frame);
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// 监听来自FSPClient的帧数据
 /// </summary>
 /// <param name="frame"></param>
 private void OnFSPListener(FSPFrame frame)
 {
     AddServerFrame(frame);
 }