public OfflineGame() { _background = new GameBackground(); _gameBoard = new GameBoard(); _player = new Player(true); _enemy = new Player(false); _enemy.GenerateRandomFleet(); IsReady(); StartButton.MouseClick += (s, e) => { _isReady = _player.IsReady(); if (!_isReady) { _alpha = 255; _message = Messages.NotReady; _messageFlag = true; } else { _playing = true; StartButton.Enabled = false; StartButton.Visible = false; ShipWarsForm.Collection.RemoveByKey("RandomButton"); ShipsToBoard(); StartButton.Dispose(); } }; }
public OnlineGame() { _background = new GameBackground(); _client = new TcpClient(); _message = "Connecting to the server"; _client.Connect("localhost", 8888); _message = "Connected\nWaiting for another player to join"; _player = new Player(true); IsReady(); foreach (var ship in _player.BattleShips) { ship.Hide(); } StartButton.Hide(); Start_Click(); _player.randomFleet.Hide(); _stream = _client.GetStream(); new Thread(ReaderHandler).Start(); _writer = new Thread(WriterHandler); }