Add FloatingTextManager and FloatingText for displaying UI messages; update CollectableComponent and HealthComponent to utilize new floating text features

This commit is contained in:
2025-09-11 04:35:30 +02:00
parent f9cb59d182
commit f229ff5b7d
16 changed files with 131 additions and 139 deletions

View File

@@ -15,12 +15,11 @@ public partial class HealthComponent : Node2D
[Signal] public delegate void HealthChangedEventHandler(float delta, float totalHealth);
[Signal] public delegate void DeathEventHandler();
private DamageNumberManager _damageNumberManager;
private FloatingTextManager _floatingTextManager;
public override void _Ready()
{
_damageNumberManager = GetNode<DamageNumberManager>("/root/DamageNumberManager");
_damageNumberManager?.Register(Owner);
_floatingTextManager = GetNode<FloatingTextManager>("/root/FloatingTextManager");
}
public void SetHealth(float newValue)
@@ -47,6 +46,11 @@ public partial class HealthComponent : Node2D
if (delta == 0.0f)
return;
if (delta < 0.0f)
_floatingTextManager?.ShowDamage(Mathf.Abs(delta), GlobalPosition);
else
_floatingTextManager?.ShowHeal(delta, GlobalPosition);
if (playSfx)
{