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:
|
@ -25,6 +25,7 @@ public class UIScript : MonoBehaviour
|
|||||||
public GameObject resourceItemPrefab;
|
public GameObject resourceItemPrefab;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Internal variables to keep track of score, health, and resources, win state
|
// Internal variables to keep track of score, health, and resources, win state
|
||||||
private int[] scores = new int[2];
|
private int[] scores = new int[2];
|
||||||
private int[] playersHealth = new int[2];
|
private int[] playersHealth = new int[2];
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 9aff5eab828ef4f6399febda5f5f27f0
|
guid: 9aff5eab828ef4f6399febda5f5f27f0
|
||||||
timeCreated: 1467931870
|
|
||||||
licenseType: Store
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
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
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user