2024-05-10 14:56:27 +00:00
|
|
|
|
using ColdMint.scripts.debug;
|
|
|
|
|
using ColdMint.scripts.map.interfaces;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.map;
|
|
|
|
|
|
|
|
|
|
public class MapGeneratorConfig : IMapGeneratorConfig
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>At least how many rooms are generated</para>
|
|
|
|
|
/// <para>至少生成多少个房间</para>
|
|
|
|
|
/// </summary>
|
2024-05-10 14:56:27 +00:00
|
|
|
|
public const int MinRoomCount = 15;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>Maximum number of rooms generated</para>
|
|
|
|
|
/// <para>最多生成多少个房间</para>
|
|
|
|
|
/// </summary>
|
2024-05-10 14:56:27 +00:00
|
|
|
|
public const int MaxRoomCount = 30;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public const int MinBranchCount = 3;
|
|
|
|
|
|
|
|
|
|
public const int MaxBranchCount = 5;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
|
|
|
|
private int _roomCount;
|
2024-05-10 14:56:27 +00:00
|
|
|
|
private int _branchCount;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
|
|
|
|
public MapGeneratorConfig(Node2D mapRoot, ulong seed)
|
|
|
|
|
{
|
|
|
|
|
MapRoot = mapRoot;
|
|
|
|
|
Seed = seed;
|
|
|
|
|
RandomNumberGenerator = new RandomNumberGenerator();
|
|
|
|
|
RandomNumberGenerator.Seed = seed;
|
2024-05-10 14:56:27 +00:00
|
|
|
|
_roomCount = RandomNumberGenerator.RandiRange(MinRoomCount, MaxRoomCount);
|
|
|
|
|
_branchCount = RandomNumberGenerator.RandiRange(MinBranchCount, MaxBranchCount);
|
|
|
|
|
LogCat.Log("Seed:" + seed + " RoomCount:" + _roomCount);
|
2024-04-28 13:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Node2D MapRoot { get; }
|
|
|
|
|
public int RoomCount => _roomCount;
|
2024-05-10 14:56:27 +00:00
|
|
|
|
public int BranchCount => _branchCount;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
|
|
|
|
public ulong Seed { get; }
|
|
|
|
|
public RandomNumberGenerator RandomNumberGenerator { get; }
|
|
|
|
|
}
|