private void DrawShips(Canvas canvas, BattleShipsPlayer player) { var board = player.Board; var size = Math.Min(canvas.ActualHeight, canvas.ActualWidth); var rectSize = size / BORAD_SIZE; for (var y = 0; y < board.GetLength(0); y++) for (var x = 0; x < board.GetLength(1); x++) { if (board[y, x].HasFlag(FieldState.Water) && !board[y, x].HasFlag(FieldState.Unknown)) canvas.DrawMiss(x * rectSize, y * rectSize, (x+1) * rectSize, (y+1) * rectSize); if (board[y, x].HasFlag(FieldState.Ship) && !board[y, x].HasFlag(FieldState.Unknown)) canvas.DrawRect(x * rectSize, y * rectSize, rectSize, rectSize, Config.SHIP_HIT_COLOR); else if (board[y, x].HasFlag(FieldState.SankShip)) canvas.DrawRect(x * rectSize, y * rectSize, rectSize, rectSize, Config.SHIP_SANK_COLOR); else if (board[y, x].HasFlag(FieldState.Ship)) canvas.DrawRect(x* rectSize, y* rectSize, rectSize, rectSize, Config.SHIP_OK_COLOR); } }
private void DrawShipBorders(Canvas canvas, BattleShipsPlayer player) { var size = Math.Min(canvas.ActualHeight, canvas.ActualWidth); var rectSize = size / BORAD_SIZE; foreach (var ship in player.Ships) { canvas.DrawEmptyRect(ship.StartPoint.X*rectSize, ship.StartPoint.Y*rectSize, ship.EndPoint.X*rectSize + rectSize, ship.EndPoint.Y*rectSize + rectSize); } }