Eventy upraveny pro podporu dvou hráčů. Všechny dveře se zobrazují na správných pozicích pro oba hráče.

This commit is contained in:
Perry 2026-02-25 17:05:15 +01:00
parent cea56112ea
commit 3049417914
18 changed files with 157 additions and 75 deletions

View file

@ -6,7 +6,7 @@ public static class MapManager {
private static MapTile[,] map = new MapTile[5, 5];
public static MapTile Get((int x, int y) coords) => map[coords.x, coords.y];
public static MapTile Get(int tileId) => Get(MapTile.IdToCoords(tileId));
public static MapTile Get(int tileId) => Get(IdToCoords(tileId));
private static Dictionary<(int x1, int y1), (int x2, int y2, int value, ConnectorType type)[]> halfConnectors = new(){
@ -30,11 +30,11 @@ public static class MapManager {
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(MapTile.CoordsToId(i, j), null); // TODO: implement ownership
map[i, j] = new MapTile(CoordsToId(i, j), null); // TODO: implement ownership
}
map[i, 2] = new MapTile(MapTile.CoordsToId(i, 2), null);
map[i, 2] = new MapTile(CoordsToId(i, 2), null);
for (int j = 3; j < 5; j++){
map[i, j] = new MapTile(MapTile.CoordsToId(i, j), null);
map[i, j] = new MapTile(CoordsToId(i, j), null);
}
}
@ -69,4 +69,7 @@ public static class MapManager {
}
public const int ID_X_OFFSET = 5; // map grid height
public static int CoordsToId(int x, int y) => x * ID_X_OFFSET + y;
public static (int, int) IdToCoords(int id) => (id / ID_X_OFFSET, id % ID_X_OFFSET);
}

View file

@ -6,7 +6,7 @@ namespace FNAF_Server.Map;
public class MapTile : GlobalMapTile<TileConnector, MapTile> {
public ServerPlayer Owner{ get; private set; }
public MapTile(int id, ServerPlayer owner) : base(id) {
public MapTile(int id, ServerPlayer owner) : base(id, MapManager.IdToCoords(id)) {
Owner = owner;
}