예제 #1
0
    //this was an experiment, but it uses too many resources
    public void SpawnSurroundingBuildings(int depth)
    {
        Rect box     = world.GetBoundingBox();
        Rect surrbox = box;

        surrbox.width  += 2 * depth;
        surrbox.height += 2 * depth;
        surrbox.x      -= depth;
        surrbox.y      += depth;

        float yMax = surrbox.yMin - surrbox.height;

        Debug.Log("Spawning in " + surrbox + " vs " + box);
        //4 sides
        for (int i = (int)surrbox.xMin; i < surrbox.xMax; ++i)
        {
            for (int j = (int)surrbox.yMin; j > yMax; --j)
            {
                if (i >= box.x && i <= box.x + box.width && j <= box.y && j >= box.y - box.height)
                {
                    continue;
                }
                BuildingFactory.SpawnDecoration(i, j);
            }
        }
    }