f8590432ba
Created assemblies for the new design code. Relocated legacy scripts into a legacy folder and made a "new_design" folder for new design.
53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace Player
|
|
{
|
|
public class StatsOutputScreen : MonoBehaviour
|
|
{
|
|
[SerializeField] private TMP_Text healthText;
|
|
|
|
[SerializeField] private TMP_Text staminaText;
|
|
|
|
[SerializeField] private TMP_Text oxygenText;
|
|
|
|
[HideInInspector] public float health;
|
|
|
|
[HideInInspector] public float stamina;
|
|
|
|
[HideInInspector] public float oxygen;
|
|
|
|
private Color initColor;
|
|
|
|
// Start is called before the first frame update
|
|
private void Start()
|
|
{
|
|
initColor = healthText.color;
|
|
InvokeRepeating("ToggleColor", 0.5f, 0.5f);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
private void Update()
|
|
{
|
|
healthText.text = "Health:" + health;
|
|
|
|
if (health <= 1)
|
|
//Dark Red
|
|
healthText.color = new Color(50, 0, 0);
|
|
else if (health <= 3)
|
|
healthText.color = Color.red;
|
|
else
|
|
healthText.color = initColor;
|
|
|
|
staminaText.text = "Stamina:" + stamina;
|
|
oxygenText.text = "Oxygen:" + oxygen;
|
|
}
|
|
|
|
private void ToggleColor()
|
|
{
|
|
if (health <= 1)
|
|
healthText.gameObject.SetActive(!healthText.gameObject.activeSelf);
|
|
}
|
|
}
|
|
}
|