Update node paths and group assignments for consistency across scenes

This commit is contained in:
2025-08-26 17:45:00 +02:00
parent ca0d21e40a
commit ad53ef9715
8 changed files with 11 additions and 21 deletions

View File

@@ -35,7 +35,7 @@ public partial class ExitDoorComponent : Node, IUnlockable
if (Locked) return;
EmitSignalExitTriggered();
_gameManager.UnlockLevel((int)_gameManager.PlayerState["CurrentLevel"] + 1);
_gameManager.UnlockLevel((int)_gameManager.PlayerState["current_level"] + 1);
CallDeferred(nameof(GoToNextLevel));
}

View File

@@ -7,7 +7,7 @@ namespace Mr.BrickAdventures.scripts.components;
public partial class ScoreComponent : Node
{
private GameManager _gameManager;
private const string CoinsGroupName = "Coins";
private const string CoinsGroupName = "coins";
public override async void _Ready()
{
@@ -20,30 +20,17 @@ public partial class ScoreComponent : Node
return;
}
var coins = GetTree().GetNodesInGroup("coins");
GD.Print($"Found {coins.Count} coins in the scene.");
var coins = GetTree().GetNodesInGroup(CoinsGroupName);
foreach (var coin in coins)
{
var c = coin.GetNodeOrNull<CollectableComponent>("CollectableComponent");
GD.Print(c == null ? "CollectableComponent not found on coin." : "CollectableComponent found on coin.");
if (c != null)
{
c.Collected += OnCollected;
}
}
}
public override void _Process(double delta)
{
GetCoinsInScene();
}
private void GetCoinsInScene()
{
var coins = GetTree().GetNodesInGroup("Coins");
GD.Print($"Found {coins.Count} coins in the scene.");
}
private void OnCollected(float amount, CollectableType type, Node2D body)
{
if (type != CollectableType.Coin) return;