2024-04-10 19:25:45 +02:00
|
|
|
namespace TanksServer.GameLogic;
|
2024-04-06 13:46:34 +02:00
|
|
|
|
2024-04-07 13:02:49 +02:00
|
|
|
internal sealed class MapService
|
2024-04-06 13:46:34 +02:00
|
|
|
{
|
2024-04-12 18:32:10 +02:00
|
|
|
public const ushort TilesPerRow = 44;
|
|
|
|
public const ushort TilesPerColumn = 20;
|
|
|
|
public const ushort TileSize = 8;
|
|
|
|
public const ushort PixelsPerRow = TilesPerRow * TileSize;
|
|
|
|
public const ushort PixelsPerColumn = TilesPerColumn * TileSize;
|
2024-04-06 13:46:34 +02:00
|
|
|
|
2024-04-06 20:32:54 +02:00
|
|
|
private readonly string _map =
|
|
|
|
"""
|
2024-04-12 19:49:24 +02:00
|
|
|
#######.##########################.#########
|
2024-04-06 20:32:54 +02:00
|
|
|
#...................##.....................#
|
|
|
|
#...................##.....................#
|
|
|
|
#.....####......................####.......#
|
|
|
|
#..........................................#
|
|
|
|
#............###...........###.............#
|
|
|
|
#............#...............#.............#
|
2024-04-12 19:49:24 +02:00
|
|
|
#...##.......#....#....#.....#......##.....#
|
2024-04-06 20:32:54 +02:00
|
|
|
#....#..............................#......#
|
2024-04-12 19:49:24 +02:00
|
|
|
.....#...#......................#...#.......
|
|
|
|
.....#...#......................#...#.......
|
2024-04-06 20:32:54 +02:00
|
|
|
#....#..............................#......#
|
2024-04-12 19:49:24 +02:00
|
|
|
#...##.......#....#....#.....#......##.....#
|
2024-04-06 20:32:54 +02:00
|
|
|
#............#...............#.............#
|
|
|
|
#............###...........###.............#
|
|
|
|
#..........................................#
|
|
|
|
#.....####......................####.......#
|
|
|
|
#...................##.....................#
|
|
|
|
#...................##.....................#
|
2024-04-12 19:49:24 +02:00
|
|
|
#######.##########################.#########
|
2024-04-06 20:32:54 +02:00
|
|
|
"""
|
|
|
|
.ReplaceLineEndings(string.Empty);
|
2024-04-06 13:46:34 +02:00
|
|
|
|
|
|
|
private char this[int tileX, int tileY] => _map[tileX + tileY * TilesPerRow];
|
|
|
|
|
2024-04-07 13:02:49 +02:00
|
|
|
public bool IsCurrentlyWall(TilePosition position)
|
2024-04-06 13:46:34 +02:00
|
|
|
{
|
2024-04-07 13:02:49 +02:00
|
|
|
return this[position.X, position.Y] == '#';
|
2024-04-06 13:46:34 +02:00
|
|
|
}
|
|
|
|
}
|