Add monster energy indicator

This commit is contained in:
henriquenakashima 2020-09-20 15:26:18 -04:00
parent 537538a6ca
commit 4ca7b7537a
6 changed files with 228 additions and 50 deletions

View file

@ -6,28 +6,29 @@ using UnityEngine.UI;
public class EnergyUI : MonoBehaviour
{
public Text text;
public BattleController battleController;
private int renderedEnergy = -1;
private int renderedMaxEnergy = -1;
private EnergyPool pool;
public void Init(EnergyPool pool) {
this.pool = pool;
}
// Start is called before the first frame update
void Start()
{
Render();
}
// Update is called once per frame
void Update()
private void Render()
{
if (this.renderedEnergy != battleController.GetEnergy() || this.renderedMaxEnergy != battleController.GetMaxEnergy()) {
string currentEnergyString = "" + battleController.GetEnergy();
if (battleController.GetEnergy() == 0) {
currentEnergyString = "<color=red>" + currentEnergyString + "</color>";
}
text.text = "Energy: " + currentEnergyString + " / " + battleController.GetMaxEnergy();
this.renderedEnergy = battleController.GetEnergy();
this.renderedMaxEnergy = battleController.GetMaxEnergy();
string currentEnergyString = "" + this.pool.Energy;
if (this.pool.Energy == 0) {
currentEnergyString = "<color=red>" + currentEnergyString + "</color>";
}
text.text = "Energy: " + currentEnergyString + " / " + this.pool.MaxEnergy;
}
public void NotifyEnergyChanged() {
Render();
}
}