Beispiel #1
0
        public void EnterFrame()
        {
            // 延迟移除,因为还要给些时间发包
            for (int i = 0; i < m_ListPlayersExitOnNextFrame.Count; i++)
            {
                FSPPlayer player = m_ListPlayersExitOnNextFrame[i];
                FSPServer.Instance.DelSession(player.Sid);
                player.Dispose();
            }
            m_ListPlayersExitOnNextFrame.Clear();

            // 处理状态变化
            HandleGameState();

            //经过上面状态处理之后,有可能状态还会发生变化
            if (m_State == FSPGameState.None)
            {
                return;
            }

            if (m_LockedFrame.frameId != 0 || //已经在跑逻辑了
                !m_LockedFrame.IsEmpty()     //可能还在准备阶段
                )
            {
                for (int i = m_ListPlayer.Count - 1; i >= 0; i--)
                {
                    FSPPlayer player = m_ListPlayer[i];
                    player.SendToClient(m_LockedFrame);

                    if (player.WaitForExit)
                    {
                        m_ListPlayer.RemoveAt(i);
                        m_ListPlayersExitOnNextFrame.Add(player);
                    }
                }
            }
            //0帧每个循环需要额外清除掉再重新统计
            if (m_LockedFrame.frameId == 0)
            {
                // 为了保留m_LockedFrame.vkeys,没有用Clear()来清除
                m_LockedFrame = new FSPFrame();
                m_FrameRecords.Add(m_LockedFrame);
            }

            //在这个阶段,帧号才会不停往上加
            if (m_State == FSPGameState.RoundBegin || m_State == FSPGameState.ControlStart)
            {
                m_CurFrameId++;

                m_LockedFrame         = new FSPFrame();
                m_LockedFrame.frameId = m_CurFrameId;

                m_FrameRecords.Add(m_LockedFrame);
            }
        }
Beispiel #2
0
        void RemovePlayer(uint playerId)
        {
            for (int i = 0; i < m_ListPlayer.Count; i++)
            {
                FSPPlayer player = m_ListPlayer[i];
                if (player.Id == playerId)
                {
                    m_ListPlayer.RemoveAt(i);

                    FSPServer.Instance.DelSession(player.Sid);
                    player.Dispose();
                    return;
                }
            }
        }