26 lines
865 B
C#
26 lines
865 B
C#
|
|
using GlobalClassLib;
|
||
|
|
using Microsoft.Xna.Framework;
|
||
|
|
using Microsoft.Xna.Framework.Graphics;
|
||
|
|
|
||
|
|
namespace FNAF_Clone.GUI;
|
||
|
|
|
||
|
|
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)}";
|
||
|
|
}
|