asd
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Godot;
|
||||
|
||||
@@ -5,11 +6,25 @@ namespace NodeWar.scripts.components;
|
||||
|
||||
public partial class HealthComponent : ProgressBar
|
||||
{
|
||||
private float _health = 100;
|
||||
|
||||
[Export]
|
||||
public Sprite2D Gfx { get; set; }
|
||||
|
||||
[Export]
|
||||
public float Health { get; set; } = 100;
|
||||
public float Health
|
||||
{
|
||||
get => _health;
|
||||
set
|
||||
{
|
||||
if (value >= MaxHealth)
|
||||
{
|
||||
_health = MaxHealth;
|
||||
}
|
||||
|
||||
_health = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Export]
|
||||
public float MaxHealth { get; set; } = 100;
|
||||
@@ -55,6 +70,8 @@ public partial class HealthComponent : ProgressBar
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
Visible = Math.Abs(Health - MaxHealth) > 0.001f;
|
||||
|
||||
Value = Health;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user