You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FlyingFred/Assets/UIManager.cs

39 lines
891 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.SceneManagement;
public class UIManager : MonoBehaviour
{
public TextMeshProUGUI Health;
public static UIManager instance;
public CharacterController player;
public GameObject GameOverPanel;
public CameraFollow cameraFollow;
private void Awake()
{
instance = this;
}
private void Start()
{
UpdateHealth();
}
public void UpdateHealth()
{
Health.text = "Health: " + player.Health.ToString();
if (player.Health <= 2)
{
GameOver();
}
}
void GameOver()
{
player.SpineHingeJoint.connectedBody = null;
cameraFollow.isPlaying = false;
}
public void Restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}