63 lines
946 B
C#
63 lines
946 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
#region Statication
|
|
|
|
public static GameManager instance;
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance != null && instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
DontDestroyOnLoad(this);
|
|
instance = this;
|
|
}
|
|
|
|
#endregion
|
|
//this is just for general functions and variables that will be reused
|
|
public Camera camera;
|
|
public GameObject pauseMenu;
|
|
public Vector3 GetMouseWorldPos()
|
|
{
|
|
return camera.ScreenToWorldPoint(Input.mousePosition);
|
|
}
|
|
|
|
public void SetPause(bool state)
|
|
{
|
|
if (state)
|
|
{
|
|
Time.timeScale = 0f;
|
|
}
|
|
else
|
|
{
|
|
Time.timeScale = 1f;
|
|
}
|
|
}
|
|
|
|
public void SetPauseMenu()
|
|
{
|
|
if (!pauseMenu.activeSelf)
|
|
{
|
|
SetPause(true);
|
|
pauseMenu.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
pauseMenu.SetActive(false);
|
|
SetPause(false);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
SetPauseMenu();
|
|
}
|
|
}
|
|
}
|