Added Pause Script + UI
(UI script set up confusingly so I was forced to make it a seperate script)
This commit is contained in:
parent
defcc0a7a8
commit
f3ef2d4c94
1770
Unity-Files/Assets/Prefabs/UserInterface.prefab
generated
1770
Unity-Files/Assets/Prefabs/UserInterface.prefab
generated
File diff suppressed because it is too large
Load Diff
43
Unity-Files/Assets/Scripts/Gameplay/PauseMenu.cs
Normal file
43
Unity-Files/Assets/Scripts/Gameplay/PauseMenu.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PauseMenu : MonoBehaviour
|
||||
{
|
||||
public GameObject pausePanel;
|
||||
private bool paused = false;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
if(paused == true)
|
||||
{
|
||||
unpauseGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
pauseGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pauseGame()
|
||||
{
|
||||
paused = true;
|
||||
pausePanel.SetActive(true);
|
||||
Time.timeScale = 0;
|
||||
}
|
||||
void unpauseGame()
|
||||
{
|
||||
paused = false;
|
||||
pausePanel.SetActive(false);
|
||||
Time.timeScale = 1;
|
||||
}
|
||||
}
|
11
Unity-Files/Assets/Scripts/Gameplay/PauseMenu.cs.meta
generated
Normal file
11
Unity-Files/Assets/Scripts/Gameplay/PauseMenu.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29fab49d338cb234aa798b43e4b091da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -6,7 +6,7 @@ using UnityEngine.UI;
|
||||
[AddComponentMenu("")]
|
||||
public class UIScript : MonoBehaviour
|
||||
{
|
||||
[Header("Configuration")]
|
||||
[Header("Configuration")]
|
||||
public Players numberOfPlayers = Players.OnePlayer;
|
||||
|
||||
public GameType gameType = GameType.Score;
|
||||
@ -23,6 +23,7 @@ public class UIScript : MonoBehaviour
|
||||
public GameObject statsPanel, gameOverPanel, winPanel;
|
||||
public Transform inventory;
|
||||
public GameObject resourceItemPrefab;
|
||||
|
||||
|
||||
|
||||
// Internal variables to keep track of score, health, and resources, win state
|
||||
@ -59,8 +60,8 @@ public class UIScript : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
//version of the one below with one parameter to be able to connect UnityEvents
|
||||
public void AddOnePoint(int playerNumber)
|
||||
//version of the one below with one parameter to be able to connect UnityEvents
|
||||
public void AddOnePoint(int playerNumber)
|
||||
{
|
||||
AddPoints(playerNumber, 1);
|
||||
}
|
||||
|
@ -1,10 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9aff5eab828ef4f6399febda5f5f27f0
|
||||
timeCreated: 1467931870
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
defaultReferences:
|
||||
- rightLabel: {instanceID: 0}
|
||||
- leftLabel: {instanceID: 0}
|
||||
- winLabel: {instanceID: 0}
|
||||
- statsPanel: {instanceID: 0}
|
||||
- gameOverPanel: {instanceID: 0}
|
||||
- winPanel: {instanceID: 0}
|
||||
- inventory: {instanceID: 0}
|
||||
- resourceItemPrefab: {instanceID: 0}
|
||||
- pausePanel: {instanceID: 0}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
|
Loading…
x
Reference in New Issue
Block a user