// Creates a static wall if and only if at least one side of the tile set (2x2)
        public static void createEdgeWall(Tile tile, Vec2Int pos)
        {
            if (tile == null)
                return;

            Vec2Int basePos = pos;
            if (basePos.x % 2 != 0)
            {
                tile = tile.getSide(SIDE_4.LEFT);

                if (tile == null)
                    return;
            }

            if (basePos.y % 2 != 0)
            {
                tile = tile.getSide(SIDE_4.BOTTOM);

                if (tile == null)
                    return;
            }

            Map map = Map.Get();

            // If any of the sides are null, consider the tile to be a boundary.
            if (tile.getSide(SIDE_4.LEFT) == null)
            {
                PlaceableStaticWall.createStaticWall(map.toTilePos(tile.position()));
                return;
            }
            else if (tile.getSide(SIDE_4.BOTTOM) == null)
            {
                PlaceableStaticWall.createStaticWall(map.toTilePos(tile.position()));
                return;
            }

            Tile it = tile.getSide(SIDE_4.TOP);
            if (it != null && it.getSide(SIDE_4.TOP) == null)
            {
                PlaceableStaticWall.createStaticWall(map.toTilePos(tile.position()));
                return;
            }

            it = tile.getSide(SIDE_4.RIGHT);
            if (it != null && it.getSide(SIDE_4.RIGHT) == null)
            {
                PlaceableStaticWall.createStaticWall(map.toTilePos(tile.position()));
                return;
            }
        }
Esempio n. 2
0
        public Tile[,] getArea(Tile baseTile, Vec2Int size)
        {
            if (size.x < 0 || size.y < 0)
                return null;

            Tile[,] area = new Tile[size.x, size.y];

            Vec2Int basePos = baseTile.position();
            Vec2Int offset = new Vec2Int(0, 0);
            for (int i = 0; i < size.x; i++)
            {
                offset.x = i;
                for (int j = 0; j < size.y; j++)
                {
                    offset.y = j;
                    area[i, j] = getExistingTile(basePos + offset);
                }
            }

            return area;
        }
Esempio n. 3
0
 public void setTile(Vec2Int globalPosition, Tile tile)
 {
     getQuadNode(globalPosition).data(tile);
     tile.position(globalPosition);
 }