2026-03-12 22:33:35 +01:00
|
|
|
using GlobalClassLib;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
|
2026-03-22 18:31:05 +01:00
|
|
|
namespace ONDClient.GUI;
|
2026-03-12 22:33:35 +01:00
|
|
|
|
|
|
|
|
public class PowerIndicator : TextUIElement {
|
|
|
|
|
private string label;
|
|
|
|
|
private ClientPlayer player;
|
|
|
|
|
private int lastPowerValue;
|
|
|
|
|
|
|
|
|
|
public PowerIndicator(Point corner1, SpriteFont font, ClientPlayer player, string label, Alignment alignment = Alignment.LEFT) : base(corner1, font, alignment, autoBounds:true) {
|
|
|
|
|
this.player = player;
|
|
|
|
|
this.label = label;
|
|
|
|
|
lastPowerValue = player.state.power;
|
|
|
|
|
Text = GetText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Update() {
|
|
|
|
|
if (player.state.power == lastPowerValue) return;
|
|
|
|
|
lastPowerValue = player.state.power;
|
|
|
|
|
Text = GetText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetText() => $"{label}{(int)(((float)player.state.power / Power.MAX_POWER_VALUE) * 100)}";
|
|
|
|
|
}
|