Skip to content

Instantly share code, notes, and snippets.

@giljr
Last active March 13, 2018 23:30
Show Gist options
  • Save giljr/5266281c2966df36bb90facd3eddb98a to your computer and use it in GitHub Desktop.
Save giljr/5266281c2966df36bb90facd3eddb98a to your computer and use it in GitHub Desktop.
Episode#10 Unity Game
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HUD : MonoBehaviour {
public Text mTxtHealth;
public Text mTxtTime;
public RectTransform mPanelGameOver;
public Text mTxtGameOver;
// Use this for initialization
void Start ()
{
GameController.Instance.GameOverEvent += OnGameOverEvent;
}
private void OnGameOverEvent (object sender, System.EventArgs e)
{
mPanelGameOver.gameObject.SetActive(true);
mTxtGameOver.text = GameController.Instance.IsWon ? "YOU WON" : "YOU LOOSE";
}
// Update is called once per frame
void Update () {
mTxtHealth.text = GameController.Instance.Health.ToString();
mTxtTime.text = GameController.Instance.Time.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment