mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 04:55:54 +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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Components.FSM;
|
||||
using Cirno.Scripts.Enums;
|
||||
using Cirno.Scripts.Misc;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot.Collections;
|
||||
|
|
@ -74,7 +75,19 @@ public partial class GameManager : Node2D
|
|||
{
|
||||
Instance = this;
|
||||
RenderingServer.SetDefaultClearColor(Colors.Black);
|
||||
GlobalState.Session.LevelNumber = MapResource.LevelId;
|
||||
if (GlobalState.Instance.SessionSettings.GameMode is GameMode.Roguelite)
|
||||
{
|
||||
if (GlobalState.Instance.SessionSettings.LevelNumber < 0)
|
||||
{
|
||||
// TODO: Change based on which level we're going to
|
||||
GlobalState.Instance.SessionSettings.LevelNumber = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalState.Session.LevelNumber = MapResource.LevelId;
|
||||
}
|
||||
|
||||
|
||||
GlobalState.Instance.ResizeCursor();
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,16 @@ public partial class MainMenu : CanvasLayer
|
|||
SpawnMenu<OptionsMenu>(OptionsMenuTemplate, SubMenuHolder);
|
||||
}
|
||||
|
||||
private void OnRogueliteButtonPressed()
|
||||
{
|
||||
GlobalState.Session.NewSession();
|
||||
GlobalState.Session.AllowSaving = false;
|
||||
GlobalState.Session.Difficulty = DifficultyLevel.Normal;
|
||||
GlobalState.Session.GameMode = GameMode.Roguelite;
|
||||
GlobalState.Session.LevelNumber = 0;
|
||||
GlobalState.Instance.GotoScene("uid://bf1kqr3o6r6d4");
|
||||
}
|
||||
|
||||
private void _on_mainmenu_button_pressed()
|
||||
{
|
||||
if (MainMenuScene != null)
|
||||
|
|
|
|||
20
Scripts/Resources/RogueliteFloorResource.cs
Normal file
20
Scripts/Resources/RogueliteFloorResource.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class RogueliteFloorResource : Resource
|
||||
{
|
||||
[Export] public int DungeonLength { get; set; } = 3;
|
||||
[Export] public int MaxBranchLength { get; set; } = 2;
|
||||
[Export] public int MaxRooms = 12;
|
||||
[Export] public int MinKeys = 0;
|
||||
[Export] public int MaxKeys = 2;
|
||||
[Export] public int MinSecrets = 1;
|
||||
[Export] public int MaxSecrets = 1;
|
||||
[Export] public int MinTreasures = 1;
|
||||
[Export] public int MaxTreasures = 1;
|
||||
[Export] public int MinShops = 1;
|
||||
[Export] public int MaxShops = 1;
|
||||
[Export] public float EnemyHealthMultiplier = 1.1f;
|
||||
}
|
||||
1
Scripts/Resources/RogueliteFloorResource.cs.uid
Normal file
1
Scripts/Resources/RogueliteFloorResource.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b1mvbcwsip0mv
|
||||
|
|
@ -48,6 +48,9 @@ public partial class RogueliteMapTheme : Resource
|
|||
[ExportCategory("Rooms")]
|
||||
[Export] public Array<RogueliteRoomResource> Rooms { get; set; }
|
||||
|
||||
[ExportCategory("Floors")]
|
||||
[Export] public Array<RogueliteFloorResource> Floors { get; set; } = [];
|
||||
|
||||
[ExportCategory("Loot Counts")] public int MaxChestLoot { get; set; } = 100;
|
||||
|
||||
public Queue<LootItem> ChestLootQueue { get; private set; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue