private void Populate() { var mazeConfig = new MazeConfig { ConnectLeft = false, StraightPassageways = false, ConnectCenter = true }; var maze = MazeBuilder.Generate(map.Width, map.Height, mazeConfig); foreach (var cell in map.Cells) { switch (maze.Map[cell.X, cell.Y]) { case MazeBuilder.CellType.Wall: cell.CellType = CellType.Wall; break; case MazeBuilder.CellType.Door: cell.CellType = CellType.Door; // cell.Item = new Item("Door", "D", ConsoleColor.Magenta); break; case MazeBuilder.CellType.StairsUp: cell.CellType = CellType.StairsAscending; break; case MazeBuilder.CellType.StairsDown: cell.CellType = CellType.StairsDescending; break; case MazeBuilder.CellType.Open: cell.CellType = CellType.Open; break; } } var distributionOfMonsters = new Distribution <Monster> { { 2, MonsterFactory.Goblin }, { 1, MonsterFactory.Troll }, }; var distributionOfItems = new Distribution <Item> { { 20, ItemFactory.Coin }, { 20, ItemFactory.Coins }, { 10, () => new HealthPotion(R.Dice(4) * 20) }, { 05, () => new TeleportPotion(map) }, { 02, ItemFactory.Dagger }, { 01, ItemFactory.Sword }, }; var cells = map.Cells.Where(c => !c.Obstructing); Queue <Item> items = null; foreach (var cell in cells) { if (items == null || items.Count <= 0) { items = distributionOfItems.RandomQueue(); } if (R.Chance(.02) && cell.Monster == null) { cell.Monster = distributionOfMonsters.PickRandom(); } if (R.Chance(.02) && cell.Item == null) { cell.Item = /*distributionOfItems.PickRandom();*/ items.Dequeue(); } } }