Skip to content

Commit

Permalink
Added ability to pause the gameController
Browse files Browse the repository at this point in the history
(And removed debug damage button)
  • Loading branch information
bedder committed Nov 28, 2014
1 parent edd099d commit 17bb75e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
5 changes: 0 additions & 5 deletions Assets/Scripts/Player/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ void performActions() {
//If no enemies in cell, allow to teleport
teleportController.teleport();
}

// DEBUG BINDINGS BELOW THIS POINT
if (Input.GetButton("DEBUGDAMAGE")) {
damage(10);
}
}

public virtual void performClassAction() {
Expand Down
15 changes: 14 additions & 1 deletion Assets/Scripts/PlayerGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public class PlayerGUI : MonoBehaviour {
private float displayLevelNumberFor = 2f;
private float displayLevelNumberUntil;

private bool paused = false;
private float lastPause = 0f;

void Start() {
goal = GameObject.FindObjectOfType<Goal>();
countdown = GameObject.FindObjectOfType<TeleportCountdown>();
Expand Down Expand Up @@ -170,9 +173,19 @@ void OnGUI() {
drawText(timer, countdown.timeLeft().ToString("00.0000"), timerStyle, 2);
GUI.EndGroup();

if (Time.time < displayLevelNumberUntil) {
if (Input.GetButtonDown("Pause") && (Time.realtimeSinceStartup - lastPause) > 0.01f) {
paused = !paused;
lastPause = Time.realtimeSinceStartup; // TODO: Remove hackyness
Time.timeScale = paused ? 0 : 1;
Debug.Log("" + paused + "," + Time.timeScale);
}

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

}

void updateValues() {
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/InputManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ InputManager:
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: DEBUGDAMAGE
m_Name: Pause
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: '-'
positiveButton: escape
altNegativeButton:
altPositiveButton:
gravity: 3
Expand Down

0 comments on commit 17bb75e

Please sign in to comment.