/// <summary> /// Generates the map. /// </summary> protected virtual void Generate() { SadConsoleMap = new SadConsole.Maps.MapConsole(MapWidth, MapHeight); GoRogueMap = new GoRogue.MapViews.ArrayMap <bool>(MapWidth, MapHeight); // Generate rooms var mapRooms = GoRogue.MapGeneration.Generators.RoomsGenerator.Generate(GoRogueMap, Settings.RoomsCountMin, Settings.RoomsCountMax, Settings.RoomsSizeMin, Settings.RoomsSizeMax, Settings.RoomsSizeFontRatioX, Settings.RoomsSizeFontRatioY); // Generate maze GoRogue.MapGeneration.Generators.MazeGenerator.Generate(GoRogueMap, Settings.MazeChangeDirectionImprovement); // Conenct rooms to maze var connections = GoRogue.MapGeneration.Connectors.RoomDoorConnector.ConnectRooms(GoRogueMap, mapRooms, Settings.RoomsConnectionsMinSides, Settings.RoomsConnectionsMaxSides, Settings.RoomsConnectionsCancelSideSelectChance, Settings.RoomsConnectionsCancelPlacementChance, Settings.RoomsConnectionsCancelPlacementChanceIncrease); // Transform rooms into regions Rooms = (from c in connections let innerRect = (Rectangle)c.Room let outerRect = (Rectangle)c.Room.Expand(1, 1) select new Region() { IsRectangle = true, InnerRect = innerRect, OuterRect = outerRect, InnerPoints = new List <Point>(innerRect.GetPoints()), OuterPoints = new List <Point>(outerRect.GetPoints()), Connections = c.Connections.SelectMany(a => a).Select(a => (Point)a).ToList() }).ToList(); // Copy regions to map SadConsoleMap.Regions = new List <Region>(Rooms); // Create tiles in the SadConsole map foreach (var position in GoRogueMap.Positions()) { if (GoRogueMap[position]) { SadConsoleMap[position] = Tile.Factory.Create(Settings.TileBlueprintFloor); } else { SadConsoleMap[position] = Tile.Factory.Create(Settings.TileBlueprintWall); } } foreach (var region in Rooms) { foreach (var point in region.InnerPoints) { SadConsoleMap[point].SetFlag(TileFlags.RegionLighted); } } }
public DungeonScreen(SadConsole.Maps.MapConsole map) { // Setup map Map = map; Map.Position = ScreenRegionMap.Location; Map.ViewPort = new Rectangle(0, 0, ScreenRegionMap.Width, ScreenRegionMap.Height); // Setup actions ActionProcessor = new SadConsole.Actions.ActionStack(); ActionProcessor.Push(new SadConsole.Actions.ActionDelegate(ActionKeyboardProcessor)); // Setup messages Messages = new MessageConsole(ScreenRegionMessages.Width, ScreenRegionMessages.Height); Messages.Position = ScreenRegionMessages.Location; Children.Add(Messages); Children.Add(Map); }