added basic pause menu

This commit is contained in:
slevy14
2023-04-25 10:59:49 -07:00
parent 34bb1be2fb
commit cea079d243
9 changed files with 666 additions and 43 deletions

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PauseController : MonoBehaviour
{
public bool isPaused = false;
public GameObject pauseMenuCanvas;
void Awake() {
TogglePauseMenu(false);
}
void OnPause() {
if (!isPaused) {
Time.timeScale = 0;
TogglePauseMenu(true);
} else {
Time.timeScale = 1;
TogglePauseMenu(false);
}
isPaused = !isPaused;
}
void TogglePauseMenu(bool showPauseMenu) {
pauseMenuCanvas.SetActive(showPauseMenu);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cfde94a1d6dbc4cb49a9a7530cb6f6e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -132,11 +132,14 @@ public class PlayerBehavior : MonoBehaviour
}
void LetGoOfGrapple() {
if (tambourine != null && grapplingRope.isGrappling)
{
bool currentlyPaused = GameObject.Find("PauseMenu").GetComponent<PauseController>().isPaused;
if (grapplingRope.isGrappling && !currentlyPaused) {
print("currently paused is " + currentlyPaused + ", releasing grapple");
if (tambourine != null) {
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
}
grapplingGun.ReleaseGrapple();
}
}
void OnTriggerEnter2D(Collider2D col)