27 lines
No EOL
903 B
C#
27 lines
No EOL
903 B
C#
using GlobalClassLib;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using ONDClient.Net;
|
|
|
|
namespace ONDClient.GUI;
|
|
|
|
public class PowerIndicator : TextUIElement {
|
|
private readonly string label;
|
|
private readonly 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)}";
|
|
} |