From d77cd51742cb760f5f2e8f5f3c283e311ffffe1c Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Fri, 13 Oct 2017 22:11:33 +0200 Subject: Added new method for pausing the game --- td/Assets/Scripts/player.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'td/Assets/Scripts/player.cs') 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; + } + } -- cgit v1.2.3