Skip to content

Commit

Permalink
Added display of level number
Browse files Browse the repository at this point in the history
  • Loading branch information
bedder committed Nov 28, 2014
1 parent e63a85e commit edd099d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Assets/Scripts/PlayerGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class PlayerGUI : MonoBehaviour {
private TeleportCountdown countdown;
private PlayerController player;
private Gun gun;
private GameController gameController;

private int healthbarHeight = 20;
private int healthbarWidth; // Set automatically w/ respect to screen width
Expand Down Expand Up @@ -59,12 +60,18 @@ public class PlayerGUI : MonoBehaviour {

private GUIStyle deathMessageStyle;

private float displayLevelNumberFor = 2f;
private float displayLevelNumberUntil;

void Start() {
goal = GameObject.FindObjectOfType<Goal>();
countdown = GameObject.FindObjectOfType<TeleportCountdown>();
player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
gameController = GameObject.FindObjectOfType<GameController>();
gun = player.gun;

displayLevelNumberUntil = Time.time + displayLevelNumberFor;

barStyle = new GUIStyle();
barTexture = new Texture2D(1, 1);
barStyle.normal.background = barTexture;
Expand Down Expand Up @@ -162,6 +169,10 @@ void OnGUI() {
GUI.BeginGroup(timerGroup);
drawText(timer, countdown.timeLeft().ToString("00.0000"), timerStyle, 2);
GUI.EndGroup();

if (Time.time < displayLevelNumberUntil) {
drawText(new Rect(0, 0, Screen.width, Screen.height), "Level " + (gameController.nextLevel - 1), deathMessageStyle, 3);
}
}

void updateValues() {
Expand Down

0 comments on commit edd099d

Please sign in to comment.