private void Handle() { if (result[1].GetType() == typeof(ServerToClient)) { ServerToClient command = (ServerToClient)result[1]; if (command == ServerToClient.Hit) { attackBoard.UpdateBoard((Vector2i)result[2], true); attackCanvas.InvalidateVisual(); } else if (command == ServerToClient.Miss) { attackBoard.UpdateBoard((Vector2i)result[2], false); attackCanvas.InvalidateVisual(); } else if (command == ServerToClient.Win) { player.AddWin(); player.AddHits(attackBoard.hits); player.AddMiss(attackBoard.misses); mainWindow.UpdateStats(); mainWindow.Activate(); mainWindow.IsEnabled = true; gameOver = true; } else if (command == ServerToClient.Loss) { player.AddLoss(); player.AddHits(attackBoard.hits); player.AddMiss(attackBoard.misses); mainWindow.UpdateStats(); mainWindow.Activate(); mainWindow.IsEnabled = true; gameOver = true; } else if (command == ServerToClient.BattleReady) { this.Show(); } else if (command == ServerToClient.YourTurn) { //Added if something special should happen } else if (command == ServerToClient.EnemyAttack) { enemyAttacks.UpdateBoard((Vector2i)result[2], (bool)result[3]); shipCanvas.InvalidateVisual(); } else if (command == ServerToClient.EnemyUsername) { Title = string.Format("Enemy: {0}", (string)result[2]); } else if (command == ServerToClient.EnemyShips) { attackCanvas.SetShipBoard((ShipBoard)result[2]); attackCanvas.drawBlanks = false; attackCanvas.drawShips = true; attackCanvas.InvalidateVisual(); } } }