egrading armor and universal veil

This commit is contained in:
Rendo 2025-07-01 14:53:12 +05:00
commit 29254dbda0
22 changed files with 142 additions and 30 deletions

View file

@ -0,0 +1,33 @@
using Godot;
using Godot.Collections;
namespace Newlon.Components.Zombies;
public partial class DegradingSprite : Sprite2D
{
[Export] private Armor armor;
[Export] private Array<Texture2D> degradationStages;
[Export] private Array<float> thresholdPercentage;
public override void _Ready()
{
armor.ArmorDamaged += OnZombieHPChanged;
}
private void OnZombieHPChanged(int hp)
{
float percent = (float)hp / (float)armor.MaxHP;
for (int i = 0; i < degradationStages.Count; i++)
{
if (percent <= thresholdPercentage[i])
{
Texture = degradationStages[i];
}
else
{
break;
}
}
}
}