Set rooms to be generated in the middle range of outcomes 4-10
This commit is contained in:
parent
401e93075d
commit
d7af8dc4c2
16 changed files with 15675 additions and 17 deletions
|
|
@ -11,15 +11,15 @@ class Program
|
|||
{
|
||||
// Create an instance of your DungeonMapGenerator class
|
||||
var generator = new DungeonGenerator();
|
||||
generator.GenerateDungeon(25, .5f);
|
||||
|
||||
// Call the method you want to run
|
||||
DungeonMap map = generator.GenerateDungeon(25, .5f);
|
||||
int width = 30;
|
||||
int height = 20;
|
||||
DungeonMap map = generator.GenerateDungeon(width, height, 5);
|
||||
DungeonLockPopulator.PopulateLocksOfDungeon(map);
|
||||
DungeonMapSerializer.SerializeToFile(map, SAVED_DUNGEONS_PATH, DUNGEON_NAME );
|
||||
DungeonMapSerializer.SerializeToFile(map, SAVED_DUNGEONS_PATH, $"{DUNGEON_NAME} {width}x{height}" );
|
||||
|
||||
// Print the map to the console (assuming it returns a string or something printable)
|
||||
Console.WriteLine(map.GetMapAsString());
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -17,10 +17,10 @@ namespace DungeonMapGenerator
|
|||
private int _xLength = 40;
|
||||
private int _yLength = 28;
|
||||
|
||||
public DungeonMap GenerateDungeon(int length, float monsterRoomRatio)
|
||||
public DungeonMap GenerateDungeon(int xlength, int yLength, int numberOfMonsterRooms)
|
||||
{
|
||||
_xLength = 40;
|
||||
_yLength = 28;
|
||||
_xLength = xlength;
|
||||
_yLength = yLength;
|
||||
|
||||
Random random = new Random();
|
||||
DungeonMap dungeonMap = new DungeonMap(_xLength, _yLength);
|
||||
|
|
@ -29,7 +29,6 @@ namespace DungeonMapGenerator
|
|||
dungeonMap.AddRoom(GenerateOnlyBossRoom(_xLength, _yLength, WIDTH_OF_BOSS, HEIGHT_OF_BOSS));
|
||||
|
||||
EvenDisperser disperser = new EvenDisperser(_xLength, _yLength, dungeonMap.GetUnoccupiedPoints()); //TODO calculate L and W from length
|
||||
int numberOfMonsterRooms = 7; // TODO: Calculate from ratio
|
||||
|
||||
for (var i = 0; i < numberOfMonsterRooms; i ++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace DungeonMapGenerator
|
|||
{
|
||||
foreach (Room room in locklessRooms)
|
||||
{
|
||||
room.Lock = Lock.PossibleLocks[random.Next(0, Lock.PossibleLocks.Count)];
|
||||
room.Lock = Lock.NormalLocks[random.Next(0, Lock.NormalLocks.Count)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ namespace DungeonMapGenerator
|
|||
if (room.Lock == null)
|
||||
{
|
||||
Console.WriteLine($"Room at {room.GetCenterOfRoom()} wasn't seen whilst populating locks");
|
||||
room.Lock = Lock.PossibleLocks[random.Next(0, Lock.PossibleLocks.Count)];
|
||||
room.Lock = Lock.NormalLocks[random.Next(0, Lock.NormalLocks.Count)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ namespace DungeonMapGenerator
|
|||
private static List<Lock> GenerateLocks(List<Lock> pregeneratedLocks, int numLocks, float successChance)
|
||||
{
|
||||
List<Lock> locks = new List<Lock>();
|
||||
if (FindCombination(pregeneratedLocks, locks, numLocks, successChance, Lock.PossibleLocks))
|
||||
if (FindCombination(pregeneratedLocks, locks, numLocks, successChance, Lock.NormalLocks))
|
||||
{
|
||||
return locks;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace DungeonMapGenerator
|
|||
// Check if the file exists and rename it
|
||||
while (File.Exists(filePath))
|
||||
{
|
||||
filePath = Path.Combine(directoryPath, $"{name}{counter:00}.json"); // e.g., name01.json, name02.json
|
||||
filePath = Path.Combine(directoryPath, $"{name}({counter:00}).json"); // e.g., name01.json, name02.json
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@ namespace DungeonMapGenerator
|
|||
{
|
||||
public class Lock
|
||||
{
|
||||
public static readonly List<Lock> PossibleLocks = new List<Lock>()
|
||||
public static readonly List<Lock> NormalLocks = new List<Lock>()
|
||||
{
|
||||
new Lock("="),
|
||||
new Lock("2"),
|
||||
new Lock("3"),
|
||||
new Lock("4"),
|
||||
new Lock("5"),
|
||||
new Lock("6"),
|
||||
|
|
@ -18,8 +16,18 @@ namespace DungeonMapGenerator
|
|||
new Lock("8"),
|
||||
new Lock("9"),
|
||||
new Lock("10"),
|
||||
new Lock("11"),
|
||||
new Lock("12"),
|
||||
};
|
||||
|
||||
public static readonly List<Lock> HardLocks = new List<Lock>()
|
||||
{
|
||||
new Lock("3"),
|
||||
new Lock("11")
|
||||
};
|
||||
|
||||
public static readonly List<Lock> VeryHardLocks = new List<Lock>()
|
||||
{
|
||||
new Lock("2"),
|
||||
new Lock("12")
|
||||
};
|
||||
|
||||
[JsonProperty("LockType")]
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue