58 lines
1.1 KiB
C#
58 lines
1.1 KiB
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
private bool _isPause;
|
|
private InputSystem _inputSystem;
|
|
private SceneManager _sceneManager;
|
|
private TimeSystem _timeSystem;
|
|
|
|
public InputSystem Input => _inputSystem;
|
|
public SceneManager Scene => _sceneManager;
|
|
public TimeSystem Time => _timeSystem;
|
|
public static GameManager Instance { get; private set; }
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
else
|
|
Destroy(gameObject);
|
|
|
|
_inputSystem = new InputSystem();
|
|
_sceneManager = new SceneManager();
|
|
_timeSystem = new TimeSystem();
|
|
|
|
}
|
|
private void OnEnable()
|
|
{
|
|
_inputSystem.Enable();
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
_inputSystem.Disable();
|
|
}
|
|
|
|
public void Pause()
|
|
{
|
|
_isPause = true;
|
|
}
|
|
|
|
internal void Resume()
|
|
{
|
|
_isPause = false;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!_isPause)
|
|
{
|
|
_timeSystem.UpdateTime();
|
|
}
|
|
}
|
|
}
|