added basic player UI
This commit is contained in:
parent
1ba24d1faf
commit
a16601fa1d
15 changed files with 165 additions and 72 deletions
35
src/player/ui/PlayerHud.cs
Normal file
35
src/player/ui/PlayerHud.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
namespace Dancer;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class PlayerHud : Control
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Export] private Player Player { get; set; } = null!;
|
||||
|
||||
[Node] private TextureProgressBar HpBar { get; set; } = null!;
|
||||
[Node] private TextureProgressBar EnergyBar0 { get; set; } = null!;
|
||||
[Node] private TextureProgressBar EnergyBar1 { get; set; } = null!;
|
||||
[Node] private TextureProgressBar EnergyBar2 { get; set; } = null!;
|
||||
|
||||
public void OnReady() => SetProcess(true);
|
||||
|
||||
public void OnProcess(double delta)
|
||||
{
|
||||
HpBar.MinValue = 0f;
|
||||
HpBar.MaxValue = Player.MaxHealth;
|
||||
HpBar.Value = Player.Health;
|
||||
|
||||
EnergyBar0.MinValue = 0f;
|
||||
EnergyBar0.MaxValue = 1f;
|
||||
EnergyBar0.Value = Mathf.Clamp(Player.DashPoints - 0f, 0f, 1f);
|
||||
|
||||
EnergyBar1.MinValue = 0f;
|
||||
EnergyBar1.MaxValue = 1f;
|
||||
EnergyBar1.Value = Mathf.Clamp(Player.DashPoints - 1f, 0f, 1f);
|
||||
|
||||
EnergyBar2.MinValue = 0f;
|
||||
EnergyBar2.MaxValue = 1f;
|
||||
EnergyBar2.Value = Mathf.Clamp(Player.DashPoints - 2f, 0f, 1f);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue