示例#1
0
        public void PushTankGameLogic(object clientObj)
        {
            Client client = (Client)clientObj;

            GameInfoUpdate gameInfoUpdate = new GameInfoUpdate(clientGameTank);

            for (int i = 0; i < clientGameTank.Count; i++)
            {
                clientsList[i].UDPSend(gameInfoUpdate);
            }

            GameInfoSpriteUpdate gameInforSpriteUpdate = new GameInfoSpriteUpdate(tankSprite);

            for (int i = 0; i < tankSprite.Count; i++)
            {
                clientsList[i].UDPSend(gameInforSpriteUpdate);
            }

            GameInfoBombUpdate gameInfoBombUpdate = new GameInfoBombUpdate(clientBomb);

            for (int i = 0; i < clientBomb.Count; i++)
            {
                clientsList[i].UDPSend(gameInfoBombUpdate);
            }
            GameInfoBombSpriteUpdate gameInforBombSpriteUpdate = new GameInfoBombSpriteUpdate(bombSprie);

            for (int i = 0; i < bombSprie.Count; i++)
            {
                clientsList[i].UDPSend(gameInforBombSpriteUpdate);
            }
        }
示例#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)
            {
            }
        }
示例#3
0
 public void UpdateGameInfo(GameInfoUpdate gameInfo)
 {
     TankInfo   = gameInfo.UnitInfo[UnitUpdate.TypeTank];
     ScoutInfo  = gameInfo.UnitInfo[UnitUpdate.TypeScout];
     WorkerInfo = gameInfo.UnitInfo[UnitUpdate.TypeWorker];
 }
示例#4
0
 private void UpdateGameInfo(GameInfoUpdate gameInfo)
 {
     Map.Size = (gameInfo.MapWidth, gameInfo.MapHeight);
     UnitManager.UpdateGameInfo(gameInfo);
 }