Esempio n. 1
0
        private void Receive()
        {
            CheckForIllegalCrossThreadCalls = false;
            var cmd = _command.ReceiveCommand();

            switch ((Enums.Commands)cmd.Id)
            {
            case Enums.Commands.Chat:
                Chat chat = (Chat)cmd;
                ChatRichText.AppendText(chat.sender + ": " + chat.text + "\n");
                sendMsgTextBox.Clear();
                break;

            case Enums.Commands.Response:
                Response intro = (Response)cmd;
                ChatRichText.AppendText("SERVER: " + intro.text + "\n");
                break;

            case Enums.Commands.PlayerList:
                PlayerList playerList = (PlayerList)cmd;
                Helping.PlayerList(playerList, playersRichTextBox);
                _gameData.playerList = playerList;
                break;

            case Enums.Commands.TimeLeft:
                timerGame.Tick += TimerGame_Tick;

                TimeLeft time = (TimeLeft)cmd;
                dateTime = time.time;

                timerGame.Interval = 1000;
                timerGame.Start();
                //TimeLeft time = (TimeLeft) cmd;
                //timeLabel.Text = Helping.TimeLeft(time.time);
                break;

            case Enums.Commands.MapSize:
                MapSize mapSize = (MapSize)cmd;
                _gameData.mapSize = mapSize;
                _gameData.width   = formGame.Width;
                _gameData.height  = formGame.Height;
                break;

            case Enums.Commands.PlayerCoords:
                _gameData.playerCoords = (PlayerCoords)cmd;
                break;

            case Enums.Commands.VisibleObjects:
                _gameData.visibleObjects = (VisibleObjects)cmd;
                start = true;
                formGame.Invalidate();
                break;

            case Enums.Commands.VisiblePlayers:
                _gameData.visiblePlayers = (VisiblePlayers)cmd;
                break;

            case Enums.Commands.GameOver:
                MessageBox.Show("GAME OVER", "Сообщение", MessageBoxButtons.OK);
                _command.CloseConnect();
                this.Close();
                break;
            }
        }
Esempio n. 2
0
 public void ErrorsHandler(string error)
 {
     ChatRichText.AppendText("SERVER: " + error + "\n");
 }