Ejemplo n.º 1
0
        public ConnectedNicknames ConnectedNicknames(List <string> nicknames, object clientObj)
        {
            Client             client             = (Client)clientObj;
            ConnectedNicknames connectedNicksPack = new ConnectedNicknames(nicknames);

            connectedNicksPack.nicknamesConnected = clientNicknames;
            return(connectedNicksPack);
        }
Ejemplo n.º 2
0
        private void UDPServerResponse()
        {
            try
            {
                while (udpClientConnect)
                {
                    Packet udpReadPacket = UDPClientRead();
                    switch (udpReadPacket.type)
                    {
                    case PacketType.NICKNAMESCONNECTED:
                        ConnectedNicknames connectedNicknamePack = (ConnectedNicknames)udpReadPacket;
                        Console.WriteLine("Clients connected are " + connectedNicknamePack.nicknamesConnected);
                        messageForm.UpdateClientListBox(connectedNicknamePack.nicknamesConnected);
                        break;

                    case PacketType.GAMEINFORMATION:
                        GameInfoUpdate gameInfoUpdatePacket = (GameInfoUpdate)udpReadPacket;
                        mainGame.UpdateDictionaryInfo(gameInfoUpdatePacket.clientGameTankPacket);
                        mainGame.ForcePaint();
                        break;

                    case PacketType.GAMESPRITE:
                        GameInfoSpriteUpdate gameInfoSpriteUpdate = (GameInfoSpriteUpdate)udpReadPacket;
                        mainGame.UpdateSpriteInfo(gameInfoSpriteUpdate.cliengGameSpriteInfo);
                        break;

                    case PacketType.GAMEBOMBINFORMATION:
                        GameInfoBombUpdate gameInfoBombUpdatePacket = (GameInfoBombUpdate)udpReadPacket;
                        mainGame.UpdateBombDictionaryInfo(gameInfoBombUpdatePacket.clientGameBombPacket);
                        mainGame.ForcePaint();
                        break;

                    case PacketType.GAMEBOMBSPRITE:
                        GameInfoBombSpriteUpdate gameInfoBombSpriteUpdate = (GameInfoBombSpriteUpdate)udpReadPacket;
                        mainGame.UpdateBombSpriteInfo(gameInfoBombSpriteUpdate.cliengGameBombSpriteInfo);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
            }
        }