mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Floor system
This commit is contained in:
parent
8c17738371
commit
c1afa466d3
14 changed files with 199 additions and 86 deletions
|
|
@ -16,8 +16,16 @@ public partial class RogueliteRoomManager : Node2D
|
|||
{
|
||||
//[Export] public Array<RogueliteRoomResource> Rooms { get; set; }
|
||||
|
||||
[Export] public RogueliteMapTheme MapTheme { get; set; }
|
||||
[Export] public Array<RogueliteMapTheme> MapThemes { get; set; }
|
||||
|
||||
private int CurrentLevel => GlobalState.Instance.SessionSettings.LevelNumber;
|
||||
|
||||
// TODO : Get based on level number
|
||||
RogueliteMapTheme MapTheme => MapThemes[0];
|
||||
|
||||
// TODO: overflow on next theme
|
||||
private RogueliteFloorResource CurrentFloorData => MapTheme.Floors[CurrentLevel % MapTheme.Floors.Count];
|
||||
|
||||
//private Godot.Collections.Dictionary<Vector2I, RogueliteRoomResource> _grid = new();
|
||||
private Godot.Collections.Dictionary<Vector2I, RogueliteRoom> _roomGrid = new();
|
||||
|
||||
|
|
@ -26,22 +34,22 @@ public partial class RogueliteRoomManager : Node2D
|
|||
public List<RogueliteRoom> SpawnedRooms { get; private set; } = [];
|
||||
|
||||
[Export] public Vector2I SpawnOrigin { get; private set; } = Vector2I.Zero;
|
||||
|
||||
[Export] public int DungeonLength { get; set; } = 10;
|
||||
[Export] public int MaxBranches { get; set; } = 3;
|
||||
[Export] public int MaxBranchLength { get; set; } = 3;
|
||||
|
||||
[Export] public int DungeonWidth = 10;
|
||||
[Export] public int DungeonHeight = 10;
|
||||
[Export] public int MaxRooms = 12;
|
||||
[Export] public int MinKeys = 0;
|
||||
[Export] public int MaxKeys = 3;
|
||||
[Export] public int MinSecrets = 1;
|
||||
[Export] public int MaxSecrets = 2;
|
||||
[Export] public int MinTreasures = 1;
|
||||
[Export] public int MaxTreasures = 2;
|
||||
[Export] public int MinShops = 1;
|
||||
[Export] public int MaxShops = 1;
|
||||
|
||||
//[Export] public int DungeonLength { get; set; } = 10;
|
||||
// [Export] public int MaxBranches { get; set; } = 3;
|
||||
// [Export] public int MaxBranchLength { get; set; } = 3;
|
||||
//
|
||||
// [Export] public int DungeonWidth = 10;
|
||||
// [Export] public int DungeonHeight = 10;
|
||||
// [Export] public int MaxRooms = 12;
|
||||
// [Export] public int MinKeys = 0;
|
||||
// [Export] public int MaxKeys = 3;
|
||||
// [Export] public int MinSecrets = 1;
|
||||
// [Export] public int MaxSecrets = 2;
|
||||
// [Export] public int MinTreasures = 1;
|
||||
// [Export] public int MaxTreasures = 2;
|
||||
// [Export] public int MinShops = 1;
|
||||
// [Export] public int MaxShops = 1;
|
||||
[Export] public string ManualSeed { get; private set; }
|
||||
|
||||
private ulong _seed;
|
||||
|
|
@ -60,29 +68,14 @@ public partial class RogueliteRoomManager : Node2D
|
|||
public void InitSpawning()
|
||||
{
|
||||
GlobalState.Instance.SessionSettings.GameMode = GameMode.Roguelite;
|
||||
GlobalState.Instance.SessionSettings.AllowSaving = false;
|
||||
// if (GlobalState.Instance.SessionSettings.LevelNumber < 0)
|
||||
// {
|
||||
// GlobalState.Instance.SessionSettings.LevelNumber = 0;
|
||||
// }
|
||||
GenerateStraightLineDungeon();
|
||||
}
|
||||
|
||||
private void SpawnRoomsGrid()
|
||||
{
|
||||
//var firstRoom = Rooms.FirstOrDefault();
|
||||
|
||||
var origin = Vector2.Zero;
|
||||
var tileSize = new Vector2(16, 16);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
var roomIndex = GD.RandRange(0, MapTheme.Rooms.Count - 1);
|
||||
var room = MapTheme.Rooms[roomIndex];
|
||||
//SpawnRoom(room, origin + (room.Size * new Vector2(i, j) * tileSize));
|
||||
}
|
||||
}
|
||||
|
||||
//CallDeferred(MethodName.RebakeNavigationDeferred);
|
||||
}
|
||||
|
||||
|
||||
private IEnumerable<RogueliteRoomResource> StarterRooms => MapTheme.Rooms.Where(x => x.Type is RoomType.Starter);
|
||||
|
||||
private IEnumerable<RogueliteRoomResource> RegularRooms => MapTheme.Rooms.Where(x =>
|
||||
|
|
@ -118,6 +111,8 @@ public partial class RogueliteRoomManager : Node2D
|
|||
{
|
||||
SetSeed();
|
||||
|
||||
GD.Print($"Floor: {CurrentLevel}");
|
||||
|
||||
MapTheme.MakeChestLootQueue();
|
||||
MapTheme.TeleportersList = [];
|
||||
|
||||
|
|
@ -139,10 +134,10 @@ public partial class RogueliteRoomManager : Node2D
|
|||
|
||||
var offshoots = new List<RoomType>();
|
||||
|
||||
AddRandomOffshootType(offshoots, MinKeys, MaxKeys, RoomType.Key);
|
||||
AddRandomOffshootType(offshoots, MinShops, MaxShops, RoomType.Shop);
|
||||
AddRandomOffshootType(offshoots, MinSecrets, MaxSecrets, RoomType.Secret);
|
||||
AddRandomOffshootType(offshoots, MinTreasures, MaxTreasures, RoomType.Treasure);
|
||||
AddRandomOffshootType(offshoots, CurrentFloorData.MinKeys, CurrentFloorData.MaxKeys, RoomType.Key);
|
||||
AddRandomOffshootType(offshoots, CurrentFloorData.MinShops, CurrentFloorData.MaxShops, RoomType.Shop);
|
||||
AddRandomOffshootType(offshoots, CurrentFloorData.MinSecrets, CurrentFloorData.MaxSecrets, RoomType.Secret);
|
||||
AddRandomOffshootType(offshoots, CurrentFloorData.MinTreasures, CurrentFloorData.MaxTreasures, RoomType.Treasure);
|
||||
|
||||
var shuffledOffshoots = offshoots.Shuffle().ToList();
|
||||
|
||||
|
|
@ -155,7 +150,7 @@ public partial class RogueliteRoomManager : Node2D
|
|||
|
||||
bool lockNext = false;
|
||||
|
||||
for (int i = 0; i < DungeonLength; i++)
|
||||
for (int i = 0; i < CurrentFloorData.DungeonLength; i++)
|
||||
{
|
||||
GD.Print($"Dungeon room {i}");
|
||||
|
||||
|
|
@ -217,7 +212,7 @@ public partial class RogueliteRoomManager : Node2D
|
|||
|
||||
int roomsInOffshot = offshootTypeToSpawn is RoomType.Secret or RoomType.Shop
|
||||
? 0
|
||||
: GD.RandRange(0, MaxBranchLength);
|
||||
: GD.RandRange(0, CurrentFloorData.MaxBranchLength);
|
||||
|
||||
// var roomsForOffshoot = randomOffshootRoomsList
|
||||
// .Take(new Range(randOffshootStartIndex, randomOffshootRoomsList.Count - 1)).ToList();
|
||||
|
|
@ -259,9 +254,9 @@ public partial class RogueliteRoomManager : Node2D
|
|||
}
|
||||
|
||||
// Add more dungeon if not enough rooms are generated
|
||||
if (i == DungeonLength - 1 && DungeonLength < MaxRooms && currentOffshoot < DungeonLength)
|
||||
if (i == CurrentFloorData.DungeonLength - 1 && CurrentFloorData.DungeonLength < CurrentFloorData.MaxRooms && currentOffshoot < CurrentFloorData.DungeonLength)
|
||||
{
|
||||
DungeonLength++;
|
||||
CurrentFloorData.DungeonLength++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue