Refactor UI components to inherit from Control and update node paths for consistency
This commit is contained in:
@@ -20,10 +20,12 @@ public partial class ScoreComponent : Node
|
||||
return;
|
||||
}
|
||||
|
||||
var coins = GetTree().GetNodesInGroup("Coins");
|
||||
var coins = GetTree().GetNodesInGroup("coins");
|
||||
GD.Print($"Found {coins.Count} coins in the scene.");
|
||||
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;
|
||||
@@ -31,6 +33,17 @@ public partial class ScoreComponent : Node
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
Reference in New Issue
Block a user