Example #1
0
    private void SetHollows(int type, MapSetting mapSetting, Map map, System.Random seed, RoomNode room)
    {
        int hollowNums = seed.Next(mapsetting.caveNum / 2, mapsetting.caveNum);

        for (int i = 0; i <= hollowNums; i++)
        {
            Vector2Int        pos     = new Vector2Int(seed.Next(room.bottomLeft.x + 2, room.topRight.x), seed.Next(room.bottomLeft.y + 2, room.topRight.y));
            int               sizeX   = seed.Next(mapsetting.minHollowSize.x, mapSetting.maxHollowSize.x);
            int               sizeY   = seed.Next(mapsetting.minHollowSize.y, mapSetting.maxHollowSize.y);
            List <Vector2Int> hollows = new List <Vector2Int>();

            for (int x = pos.x; x < pos.x + sizeX; x++)
            {
                for (int y = pos.y; y < pos.y + sizeY; y++)
                {
                    if (room.ContainsCoordinate(x, y) && !room.Path.Contains(new Vector2Int(x, y)))
                    {
                        map.mapMatrix[x, y] = type;
                        hollows.Add(new Vector2Int(x, y));
                    }
                }
            }
            foreach (Vector2Int hole in hollows)
            {
                if (GetSurroundingSelves(hole.x, hole.y, map) < 2)
                {
                    map.mapMatrix[hole.x, hole.y] = (int)TileType.Floor;
                }
            }
        }
    }
Example #2
0
 public void BoxFill(RoomNode room, Map map, int tileType, Vector2Int centre, int width, int height)
 {
     for (int x = centre.x - width / 2; x <= centre.x + width / 2; x++)
     {
         for (int y = centre.y - height / 2; y <= centre.y + height / 2; y++)
         {
             if (room.ContainsCoordinate(x, y))
             {
                 if (map.mapMatrix[x, y] != tileType)
                 {
                     map.mapMatrix[x, y] = tileType;
                     //floorNum++;
                 }
             }
         }
     }
 }
Example #3
0
    private Vector2Int[,] SetBlockOfTiles(int tileType, Map map, RoomNode room, int sizeX, int sizeY, Vector2Int center)
    {
        Vector2Int[,] tiles = new Vector2Int[sizeX, sizeY];
        Vector2Int offset = new Vector2Int(center.x - sizeX / 2, center.y - sizeY / 2);

        for (int x = center.x - sizeX / 2; x < center.x - sizeX / 2 + sizeX; x++)
        {
            for (int y = center.y - sizeY / 2; y < center.y - sizeY / 2 + sizeY; y++)
            {
                if (room.ContainsCoordinate(x, y))
                {
                    map.mapMatrix[x, y] = tileType;
                    tiles[x - offset.x, y - offset.y] = new Vector2Int(x, y);
                }
            }
        }
        return(tiles);
    }