OneNightDuel/FNAF_Server/Map/MapManager.cs

47 lines
1.8 KiB
C#
Raw Normal View History

namespace FNAF_Server.Map;
public static class MapManager {
private static MapTile[,] map = new MapTile[5, 5];
private static Dictionary<(int x1, int y1), (int x2, int y2, int value)[]> halfConnectors = new(){
[(0, 0)] =[(1, 0, 1), (0, 1, 1)],
[(1, 0)] =[(2, 0, 1), (1, 1, 1)],
[(3, 0)] =[(2, 0, 1), (4, 0, 1), (3, 1, 1)],
[(4, 0)] =[(4, 1, 1)],
[(0, 1)] =[(1, 1, 1)],
[(1, 1)] =[(1, 2, 1)],
[(2, 1)] =[(2, 2, 1), (2, 0, 1)],
[(3, 1)] =[(3, 2, 1), (4, 1, 1)]
};
private static Dictionary<(int x1, int y1), (int x2, int y2, int value)[]> mainHallwayConnectors = new(){
[(0,2)] = [(1,2,1)],
[(1,2)] = [(2,2,1)],
[(2,2)] = [(3,2,1)],
[(3,2)] = [(4,2,1)]
};
public static void InitMap() { // TODO: make map size not hardcoded
for (int i = 0; i < 5; i++){
for (int j = 0; j < 2; j++){
map[i, j] = new MapTile(i * 5 + j, null); // TODO: implement ownership
}
map[i, 2] = new MapTile(i * 5 + 2, null);
for (int j = 3; j < 5; j++){
map[i, j] = new MapTile(i * 5 + j, null);
}
}
foreach (var con in mainHallwayConnectors){
map[con.Key.x1, con.Key.y1].AddConnectors(con.Value.Select(c => (map[c.x2, c.y2], TileConnector.ConnectorType.HALL, c.value)).ToArray());
}
foreach (var con in halfConnectors){
map[con.Key.x1, con.Key.y1].AddConnectors(con.Value.Select(c => (map[c.x2, c.y2], TileConnector.ConnectorType.HALL, c.value)).ToArray());
}
foreach (var con in halfConnectors){
map[4 - con.Key.x1, 4 - con.Key.y1].AddConnectors(con.Value.Select(c => (map[4 - c.x2, 4 - c.y2], TileConnector.ConnectorType.HALL, c.value)).ToArray());
}
}
}