Reorganize Assets/Battle
This commit is contained in:
parent
3e0004d4cb
commit
abf17d8d14
20 changed files with 16 additions and 0 deletions
33
Assets/Battle/UI/EnergyUI.cs
Normal file
33
Assets/Battle/UI/EnergyUI.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EnergyUI : MonoBehaviour
|
||||
{
|
||||
public Text text;
|
||||
public BattleController battleController;
|
||||
|
||||
private int renderedEnergy = -1;
|
||||
private int renderedMaxEnergy = -1;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue