private void ClientMessenger_OnLoadNewGame(BasePacket packet)
        {
            GameInstanceInformation gameInstance = (GameInstanceInformation)packet;

            var newScene = new GameScene(_width, _height, gameInstance.PlayerCount, gameInstance.PlayerIDs, gameInstance.PlayerNames, gameInstance.PlayerColours, gameInstance.LocalPlayerID, _client);

            newScene.Initalise(_contentManager, _graphicsDevice);
            SetNewScene(newScene);
        }
Пример #2
0
        public GameInstanceInformation MakeGameInstanceInformationPacket(int playerCount, List <ServerConnection> players, List <Color> playerColours, string localPlayerID)
        {
            GameInstanceInformation packet = new GameInstanceInformation
            {
                SendDate      = DateTime.UtcNow,
                PlayerCount   = playerCount,
                LocalPlayerID = localPlayerID
            };

            packet.PlayerIDs     = new string[packet.PlayerCount];
            packet.PlayerNames   = new string[packet.PlayerCount];
            packet.PlayerColours = new PlayerColour[packet.PlayerCount];
            for (int i = 0; i < packet.PlayerCount; i++)
            {
                packet.PlayerIDs[i]     = players[i].ID;
                packet.PlayerNames[i]   = players[i].Name;
                packet.PlayerColours[i] = MakePlayerColour(playerColours[i].R, playerColours[i].G, playerColours[i].B);
            }
            return(packet);
        }