mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
New maps and chests
This commit is contained in:
parent
7c7588c1a4
commit
26a0f51168
28 changed files with 645 additions and 233 deletions
|
|
@ -13,6 +13,7 @@ using Cirno.Scripts.Resources.Roguelite;
|
|||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using Array = Godot.Collections.Array;
|
||||
|
||||
namespace Cirno.Scripts.Controllers;
|
||||
|
||||
|
|
@ -20,6 +21,8 @@ namespace Cirno.Scripts.Controllers;
|
|||
public partial class RogueliteRoom : Node2D
|
||||
{
|
||||
[Export] public RogueliteRoomResource RoomResource { get; set; }
|
||||
|
||||
[Export] public Array<Node2D> RoomClearActivation { get; set; }
|
||||
|
||||
public RogueliteMapTheme MapTheme { get; set; }
|
||||
|
||||
|
|
@ -32,6 +35,8 @@ public partial class RogueliteRoom : Node2D
|
|||
|
||||
public Vector2 RoomSize => BaseRoomSize * RoomResource.Size;
|
||||
|
||||
[Signal] public delegate void RoomClearedEventHandler();
|
||||
|
||||
public Vector2I RandomBottomExit()
|
||||
{
|
||||
return BottomLeft + new Vector2I(GD.RandRange(0, RoomResource.Size.X - 1), 0);
|
||||
|
|
@ -324,15 +329,27 @@ public partial class RogueliteRoom : Node2D
|
|||
continue;
|
||||
}
|
||||
|
||||
double chance = GD.RandRange(0d, 100d);
|
||||
if (chance <= MapTheme.ChestChance)
|
||||
if (markerNode is ChestMarker chestMarker)
|
||||
{
|
||||
var chest = marker.CreateChild<Chest>(MapTheme.ChestPrefab);
|
||||
|
||||
var loot = MapTheme.ChestLootTable.Items.ToList().Shuffle().First();
|
||||
|
||||
chest.LootTable.Add(loot);
|
||||
double roll = GD.RandRange(0d, 100d);
|
||||
double chance = chestMarker.OverrideChance ? chestMarker.SpawnChance : MapTheme.ChestChance;
|
||||
if (roll <= chance)
|
||||
{
|
||||
|
||||
var hasLoot = MapTheme.ChestLootQueue.TryDequeue(out var loot);
|
||||
if (!hasLoot)
|
||||
{
|
||||
GD.Print("Ran out of loot to spawn");
|
||||
return;
|
||||
}
|
||||
|
||||
var chest = marker.CreateChild<Chest>(MapTheme.ChestPrefab);
|
||||
|
||||
chest.LootTable.Add(loot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -344,6 +361,7 @@ public partial class RogueliteRoom : Node2D
|
|||
if (_enemies.Count == 0)
|
||||
{
|
||||
OpenDoors();
|
||||
EmitSignalRoomCleared();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ public partial class RogueliteRoomManager : Node2D
|
|||
|
||||
var shuffledOffshoots = offshoots.Shuffle().ToList();
|
||||
|
||||
MapTheme.MakeChestLootQueue();
|
||||
|
||||
// var offshootsQueue = new Queue<RoomType>();
|
||||
// offshootsQueue.EnqueueRange(shuffledOffshoots);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue