protected override void Split(RoomGenerator roomGenerator) { var minAreaWidth = roomGenerator.MinWidth + 2; var maxAreaWidth = roomGenerator.MaxWidth + 2; if (Bounds.Width < minAreaWidth) { return; } else if (Bounds.Width > maxAreaWidth) { var splitColumn = Random.Next(minAreaWidth, Bounds.Width - minAreaWidth + 1); var width1 = splitColumn; var width2 = Bounds.Width - splitColumn + 1; if (width1 >= minAreaWidth) { SubArea1 = new VerticalArea(roomGenerator, Random, Bounds.X, Bounds.Y, width1, Bounds.Height); } if (width2 >= minAreaWidth) { SubArea2 = new VerticalArea(roomGenerator, Random, Bounds.X + splitColumn - 1, Bounds.Y, width2, Bounds.Height); } } }
protected override void Split(RoomGenerator roomGenerator) { var minAreaHeight = roomGenerator.MinHeight + 2; var maxAreaHeight = roomGenerator.MaxHeight + 2; if (Bounds.Height < minAreaHeight) { return; } else if (Bounds.Height > maxAreaHeight) { var splitRow = Random.Next(minAreaHeight, Bounds.Height - minAreaHeight + 1); var height1 = splitRow; var height2 = Bounds.Height - splitRow + 1; if (height1 >= minAreaHeight) { SubArea1 = new HorizontalArea(roomGenerator, Random, Bounds.X, Bounds.Y, Bounds.Width, height1); } if (height2 >= minAreaHeight) { SubArea2 = new HorizontalArea(roomGenerator, Random, Bounds.X, Bounds.Y + splitRow - 1, Bounds.Width, height2); } } }
public Area(RoomGenerator roomGenerator, Random random, int x, int y, int width, int height) { Random = random; Bounds = new RectI(x, y, width, height); SubArea1 = null; SubArea2 = null; Split(roomGenerator); if (!HasChildren) { Room = roomGenerator.Generate(random, this); } }
public HorizontalArea(RoomGenerator roomGenerator, Random random, int x, int y, int width, int height) : base(roomGenerator, random, x, y, width, height) { }
protected abstract void Split(RoomGenerator roomGenerator);
public BSPDungeonTileMapGenerator(int rows, int columns, RoomGenerator roomGenerator) { _rows = rows; _columns = columns; _roomGenerator = roomGenerator; }