private TileTypeReference DeserializeTileTypeReference(ValueModel model, AssemblyContext context) { TileTypeReference reference = new TileTypeReference(); reference.Assemble(model, context); return(reference); }
private TileTypeReference[,] TwodifyTiles(TileTypeReference[] walls) { TileTypeReference[,] twodi = new TileTypeReference[Width, Height]; for (int i = 0; i < walls.Length; i++) { (int x, int y) = MapUtils.IndexToCoords(i, Width); twodi[x, y] = walls[i]; } return(twodi); }
private void ResetTiles(TileType type) { Tiles = new TileTypeReference[Width, Height]; for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { Tiles[x, y] = new TileTypeReference(TileType.Empty.Name); } } }
private TileTypeReference[] EnflattenTiles(TileTypeReference[,] walls) { TileTypeReference[] flattened = new TileTypeReference[Width * Height]; for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { flattened[MapUtils.CoordsToIndex(x, y, Width)] = walls[x, y]; } } return(flattened); }
public TileTypeReference[,] GetTiles(Vector2Int from, Vector2Int to) { (from, to) = NormalizeRect(from, to); from = ClampVector(from, Vector2Int.zero, new Vector2Int(Width - 1, Height - 1)); to = ClampVector(to, Vector2Int.zero, new Vector2Int(Width - 1, Height - 1)); TileTypeReference[,] tiles = new TileTypeReference[to.x - from.x + 1, to.y - from.y + 1]; int xDelta = to.x - from.x; int yDelta = to.y - from.y; for (int y = 0; y <= yDelta; y++) { for (int x = 0; x <= xDelta; x++) { int xx = x + from.x; int yy = y + from.y; tiles[x, y] = GetTile(xx, yy); } } return(tiles); }
public void SetTile(int x, int y, TileType type) => Tiles[x, y] = new TileTypeReference(type.Name);