This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Scripts/Player/StatsOutputScreen.cs

49 lines
1.1 KiB
C#
Raw Permalink Normal View History

using TMPro;
2023-06-01 17:03:48 +02:00
using UnityEngine;
public class StatsOutputScreen : MonoBehaviour
{
2023-06-01 17:03:48 +02:00
[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;
2023-06-01 17:03:48 +02:00
// Start is called before the first frame update
2023-06-01 17:03:48 +02:00
private void Start()
{
initColor = healthText.color;
InvokeRepeating("ToggleColor", 0.5f, 0.5f);
}
// Update is called once per frame
2023-06-01 17:03:48 +02:00
private void Update()
{
2023-06-01 17:03:48 +02:00
healthText.text = "Health:" + health;
if (health <= 1)
//Dark Red
2023-06-01 17:03:48 +02:00
healthText.color = new Color(50, 0, 0);
else if (health <= 3)
healthText.color = Color.red;
else
healthText.color = initColor;
2023-06-01 17:03:48 +02:00
staminaText.text = "Stamina:" + stamina;
oxygenText.text = "Oxygen:" + oxygen;
}
private void ToggleColor()
{
2023-06-01 17:03:48 +02:00
if (health <= 1)
healthText.gameObject.SetActive(!healthText.gameObject.activeSelf);
}
2023-06-01 17:03:48 +02:00
}