示例#1
0
        public bool AddObserver(NetworkConnection connection)
        {
            bool added = false;

            if (GameState != GameStates.Finished)
            {
                ServerInitializeGameResponse packet = new ServerInitializeGameResponse();
                packet.m_field   = GameStructure.GameField;
                packet.m_ball    = GameStructure.Ball;
                packet.m_players = new Player[GameStructure.PlayersCount];
                Array.Copy(GameStructure.GetAllPlayers(), packet.m_players, GameStructure.PlayersCount);
                foreach (Player player in packet.m_players)
                {
                    player.Controllable = false;
                }
                connection.SendTCP(packet);
                connection.SendTCP(GenerateScorePackage());
                Network.AddObserver(connection);
                added = true;
            }
            return(added);
        }