public void UpdateText() { string player = _game.GetCurrentPlayer().ToString(); string color = _myColor.ToString(); string gameState = _game.GetCurrentGameState().ToString(); string turnNumber = _game.Turn.ToString(); this.Invoke((MethodInvoker)(() => { Text = "Playing as: " + color + " | " + "Waiting on: " + player + " | " + "Turn #: " + turnNumber + " | " + "Game state: " + gameState; })); // this.Text = "Playing as: " + color + " | " + "Waiting on: " + player + " | " + "Turn #: " + turnNumber + " | " + "Game state: " + gameState; }
private void DoConnection() { int requestCount = 0; while (true) { try { //NetworkStream networkStream = new NetworkStream(mySocket); if (requestCount == 0) { //SendPlayerColor(networkStream); //SendBoard(networkStream); SendPlayerColor(); SendBoard(); requestCount++; } else { //Turn obj = ReadTurnFromStream(networkStream); CheckersUtilities.Turn obj = ReadTurnFromStream(); Console.WriteLine(obj.ToString()); lock (gameBoard) { if (playerColor == gameBoard.GetCurrentPlayer()) { gameBoard.MakeTurn(obj); } else { Console.WriteLine(" " + clientString + " tried to move opponents piece"); } } otherPlayer?.Notify(); //SendBoard(networkStream); SendBoard(); requestCount++; } } catch (IOException ex) { Console.WriteLine(" >> " + ex.ToString()); Console.WriteLine(" Killing this thread - " + clientString); break; } catch (SocketException se) { Console.WriteLine(" Killing this thread - " + clientString); break; } catch (SerializationException se) { Console.WriteLine(" Killing this thread - " + clientString); break; } catch (Exception ex) { Console.WriteLine(" >> " + ex.ToString()); } } }