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:
parent
cea56112ea
commit
3049417914
18 changed files with 157 additions and 75 deletions
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices.JavaScript;
|
||||
using GlobalClassLib;
|
||||
|
||||
namespace FNAF_Clone.Map;
|
||||
|
|
@ -5,20 +7,29 @@ namespace FNAF_Clone.Map;
|
|||
public class ClientMapManager {
|
||||
private static MapTileProjection[,] map = new MapTileProjection[5, 5];
|
||||
public static MapTileProjection Get((int x, int y) coords) => map[coords.x, coords.y];
|
||||
public static MapTileProjection Get(int tileId) => Get(MapTileProjection.IdToCoords(tileId));
|
||||
public static void InitMap() {
|
||||
public static MapTileProjection Get(int tileId) => Get(IdToCoords(tileId));
|
||||
|
||||
private static bool inverted;
|
||||
public static void InitMap(bool invert = false) {
|
||||
inverted = invert;
|
||||
|
||||
IdToCoords = invert ? _IdToCoordsInverse : _IdToCoords;
|
||||
CoordsToId = invert ? _CoordsToIdInverse : _CoordsToId;
|
||||
|
||||
for (int i = 0; i < 5; i++){
|
||||
for (int j = 0; j < 2; j++){
|
||||
map[i, j] = new MapTileProjection(MapTileProjection.CoordsToId(i, j)); // TODO: implement ownership
|
||||
map[i, j] = new MapTileProjection(CoordsToId(i, j)); // TODO: implement ownership
|
||||
}
|
||||
map[i, 2] = new MapTileProjection(MapTileProjection.CoordsToId(i, 2));
|
||||
map[i, 2] = new MapTileProjection(CoordsToId(i, 2));
|
||||
for (int j = 3; j < 5; j++){
|
||||
map[i, j] = new MapTileProjection(MapTileProjection.CoordsToId(i, j));
|
||||
map[i, j] = new MapTileProjection(CoordsToId(i, j));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void InitConnectors(TileConnectorProjection[] connectors) {
|
||||
foreach (var con in connectors){
|
||||
// (int x, int y) coords1 = MapTileProjection.IdToCoords(con.Tiles.tile1.Id);
|
||||
|
|
@ -29,5 +40,16 @@ public class ClientMapManager {
|
|||
|
||||
public static TileConnectorProjection GetConnector((int, int) id) => Get(id.Item1).GetConnector(id.Item2);
|
||||
|
||||
public static TileConnectorProjection[] GetConnectors(int tileId) => Get(MapTileProjection.IdToCoords(tileId)).GetAllConnectors();
|
||||
public static TileConnectorProjection[] GetConnectors(int tileId) => Get(IdToCoords(tileId)).GetAllConnectors();
|
||||
|
||||
|
||||
|
||||
public const int ID_X_OFFSET = 5; // map grid height
|
||||
public static Func<int, int, int> CoordsToId{ get; private set; }
|
||||
public static Func<int, (int x, int y)> IdToCoords{ get; private set; }
|
||||
|
||||
private static Func<int, (int x, int y)> _IdToCoords = id => (id / ID_X_OFFSET, id % ID_X_OFFSET);
|
||||
private static Func<int, (int x, int y)> _IdToCoordsInverse = id => (ID_X_OFFSET - 1 - (id / ID_X_OFFSET), ID_X_OFFSET - 1 - (id % ID_X_OFFSET));
|
||||
private static Func<int, int, int> _CoordsToId = (x, y) => x * ID_X_OFFSET + y;
|
||||
private static Func<int, int, int> _CoordsToIdInverse = (x, y) => (ID_X_OFFSET - 1 - x) * ID_X_OFFSET + (ID_X_OFFSET - 1 - y);
|
||||
}
|
||||
|
|
@ -3,6 +3,6 @@ using GlobalClassLib;
|
|||
namespace FNAF_Clone.Map;
|
||||
|
||||
public class MapTileProjection : GlobalMapTile<TileConnectorProjection, MapTileProjection> {
|
||||
public MapTileProjection(int id) : base(id) {
|
||||
public MapTileProjection(int id) : base(id, ClientMapManager.IdToCoords(id)) {
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue