Add monster energy indicator
This commit is contained in:
parent
537538a6ca
commit
4ca7b7537a
6 changed files with 228 additions and 50 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue