Exemplo n.º 1
0
        private TileTypeReference DeserializeTileTypeReference(ValueModel model, AssemblyContext context)
        {
            TileTypeReference reference = new TileTypeReference();

            reference.Assemble(model, context);
            return(reference);
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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);
         }
     }
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public void SetTile(int x, int y, TileType type) => Tiles[x, y] = new TileTypeReference(type.Name);