Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class GameManager : MonoBehaviour
- {
- [SerializeField]
- private bool _isGameOver = false;
- [SerializeField]
- public bool _isCoOpMode = false;
- [SerializeField]
- private GameObject CoOpPlayers;
- [SerializeField]
- private GameObject _pauseMenu;
- private Animator _pauseAnim;
- private void Start()
- {
- _pauseAnim = GameObject.Find("pause_menu").GetComponent<Animator>();
- _pauseAnim.updateMode = AnimatorUpdateMode.UnscaledTime;
- }
- private void Update()
- {
- if (Input.GetKeyDown(KeyCode.R) && _isGameOver == true)
- {
- if (_isCoOpMode == false)
- {
- SceneManager.LoadScene(1);
- }
- else
- {
- SceneManager.LoadScene(2);
- }
- if (_isCoOpMode == true)
- {
- Instantiate(CoOpPlayers, Vector3.zero, Quaternion.identity);
- }
- }
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- Application.Quit();
- }
- if (Input.GetKeyDown(KeyCode.M) && _isGameOver == true)
- {
- SceneManager.LoadScene(0);
- }
- if (Input.GetKeyDown(KeyCode.P))
- {
- //This functionality could be used to slow down, speed up, and even stop time could be used in other games.
- Time.timeScale = 0f;
- _pauseMenu.SetActive(true);
- _pauseAnim.SetBool("isPaused", true);
- }
- }
- public void GameOver()
- {
- _isGameOver = true;
- }
- public void ResumeGame()
- {
- Time.timeScale = 1f;
- _pauseMenu.SetActive(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement