diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-13 22:11:33 +0200 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-13 22:11:33 +0200 |
commit | d77cd51742cb760f5f2e8f5f3c283e311ffffe1c (patch) | |
tree | a60aaccbbe51c2202e596c22d3741370fdc357d2 /td/Assets/Scripts/player.cs | |
parent | 112a91b7084a5365291c712fabcb8ceeb4c644ce (diff) | |
download | TD-d77cd51742cb760f5f2e8f5f3c283e311ffffe1c.tar.gz TD-d77cd51742cb760f5f2e8f5f3c283e311ffffe1c.zip |
Added new method for pausing the game
Diffstat (limited to 'td/Assets/Scripts/player.cs')
-rw-r--r-- | td/Assets/Scripts/player.cs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/td/Assets/Scripts/player.cs b/td/Assets/Scripts/player.cs index a8106d3..cb55357 100644 --- a/td/Assets/Scripts/player.cs +++ b/td/Assets/Scripts/player.cs @@ -1,13 +1,12 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class Player : MonoBehaviour { public int InitialHealth; public int StartingMoney; public MainGui MainGui; - + + private int _gameState; private GameObject[] _towers; private int _playerMoney; private int _playerScore; @@ -18,6 +17,7 @@ public class Player : MonoBehaviour { _playerMoney = StartingMoney; _playerHealth = InitialHealth; InvokeRepeating ("GameStateWatcher", 0f, 0.5f); + _gameState = 1; } #region stats @@ -67,4 +67,19 @@ public class Player : MonoBehaviour { } } + public bool GameIsPaused() { + if (_gameState == 0) { return true; } + return false; + } + + public void PauseGame() { + Time.timeScale = 0.0F; + _gameState = 0; + } + + public void ResumeGame() { + Time.timeScale = 1.0F; + _gameState = 1; + } + } |