예제 #1
0
    public override bool Place(Container2D <GenSpace> grid, LayoutObject obj, Theme theme, System.Random rand, out Boxing placed)
    {
        List <Bounding> options = obj.FindRectangles(GridWidth, GridLength, true, UnitTest);

        options = new List <Bounding>(options.Filter((bounds) =>
        {
            Counter counter = new Counter();
            grid.DrawRect(new Bounding(bounds, 1), FrontTest.IfThen(Draw.Count <GenSpace>(counter)));
            return(counter > 0);
        }));
        if (options.Count == 0)
        {
            placed = null;
            return(false);
        }
        #region DEBUG
        if (BigBoss.Debug.logging(Logs.LevelGen) && BigBoss.Debug.Flag(DebugManager.DebugFlag.FineSteps))
        {
            BigBoss.Debug.w(Logs.LevelGen, "Options:");
            if (GridWidth == 1 && GridLength == 1)
            {
                MultiMap <GenSpace> tmp = new MultiMap <GenSpace>();
                tmp.PutAll(obj);
                foreach (Bounding bounds in options)
                {
                    tmp.DrawRect(bounds, Draw.SetTo(GridType.INTERNAL_RESERVED_CUR, theme));
                }
                tmp.ToLog(Logs.LevelGen);
            }
            else
            {
                foreach (Bounding bounds in options)
                {
                    MultiMap <GenSpace> tmp = new MultiMap <GenSpace>();
                    tmp.PutAll(obj);
                    tmp.DrawRect(bounds, Draw.SetTo(GridType.INTERNAL_RESERVED_CUR, theme));
                    tmp.ToLog(Logs.LevelGen);
                }
            }
        }
        #endregion
        // Place startpoints
        placed = null;
        return(false);

        //placed = options.Random(rand);
        placed.Expand(1);
        GridLocation side = GridLocation.BOTTOMRIGHT;
        foreach (GridLocation loc in GridLocationExt.Dirs().Randomize(rand))
        {
            if (obj.DrawEdge(placed, loc, UnitTest, false))
            {
                side = loc;
                break;
            }
        }
        obj.DrawEdge(placed, side, Draw.SetTo(GridType.StairPlace, theme), false);
        return(true);
    }
예제 #2
0
    public override bool Place(Container2D <GenSpace> grid, LayoutObject obj, Theme theme, Random rand, out Boxing placed)
    {
        int           max     = Math.Max(GridWidth, GridLength);
        List <Boxing> options = new List <Boxing>(
            grid.FindBoxes(
                GridWidth,
                GridLength,
                GridLocation.TOP,
                new BoxedAction <GenSpace>(
                    frontTest.And(Draw.ContainedIn(obj)),
                    unitTest),
                true,
                true,
                obj.Bounding.Expand(max))
            .Filter((box) =>
        {
            Counter counter = new Counter();
            bool ret        = grid.DrawEdge(box, box.Front,
                                            Draw.HasAround(false,
                                                           Draw.And(Draw.IsType <GenSpace>(GridType.Floor), Draw.Count <GenSpace>(counter)).
                                                           Or(Draw.Walkable())));
            return(ret && counter > 0);
        }));

        if (options.Count == 0)
        {
            placed = null;
            return(false);
        }
        #region DEBUG
        if (BigBoss.Debug.logging(Logs.LevelGen) && BigBoss.Debug.Flag(DebugManager.DebugFlag.FineSteps))
        {
            BigBoss.Debug.w(Logs.LevelGen, "Options:");
            foreach (Boxing boxing in options)
            {
                MultiMap <GenSpace> tmp = new MultiMap <GenSpace>();
                tmp.PutAll(obj);
                tmp.DrawRect(boxing, Draw.SetTo(GridType.INTERNAL_RESERVED_CUR, theme));
                tmp.DrawEdge(boxing, boxing.Front, Draw.SetTo(GridType.INTERNAL_RESERVED_BLOCKED, theme));
                tmp.ToLog(Logs.LevelGen);
            }
        }
        #endregion
        // Place startpoints
        placed = options.Random(rand);
        obj.DrawEdge(placed, placed.Front, Draw.Around(false, Draw.IsType <GenSpace>(GridType.Floor).IfThen(Draw.SetTo(GridType.StairPlace, theme))));
        return(true);
    }