예제 #1
0
    private void AddRegion(Region region, bool isCorrdior = false)
    {
        int translatedX = region.outerBounds.x - generationBounds.x,
            translatedY = region.outerBounds.y - generationBounds.y;

        //Debug.Log(region.bounds.ToString() + " -> " + translatedX + ", " + translatedY);

        // Add to region map
        for (int x = translatedX; x < translatedX + region.outerBounds.size.x; x++)
        {
            for (int y = translatedY; y < translatedY + region.outerBounds.size.y; y++)
            {
                regionMap[x, y] = new RegionSpot(region.type, region.Id);
            }
        }

        regions.Add(region);
        if (isCorrdior)
        {
            corridors.Add(region);
        }
        else
        {
            rooms.Add(region);
        }
    }
예제 #2
0
    private void InitializeMap()
    {
        if (tileParent != null)
        {
            Destroy(tileParent);
            tileParent = null;
        }
        tileParent = new GameObject("Tile Map");
        if (furnitureParent != null)
        {
            Destroy(furnitureParent);
            furnitureParent = null;
        }
        furnitureParent = new GameObject("Obstacles");

        // Reset region ids
        Region.NEXT_ID = 0;

        regions   = new List <Region>();
        corridors = new List <Region>();
        rooms     = new List <Region>();

        //map = new TileType[generationBounds.size.x, generationBounds.size.y];
        regionMap = new RegionSpot[generationBounds.size.x, generationBounds.size.y];
        tileMap   = new GameObject[generationBounds.size.x, generationBounds.size.y];

        for (int x = 0; x < generationBounds.size.x; x++)
        {
            for (int y = 0; y < generationBounds.size.y; y++)
            {
                regionMap[x, y] = new RegionSpot(RegionType.None, -1);
                tileMap[x, y]   = null;
            }
        }

        numAddRoom = 0;
        numAddCor  = 0;
    }