Refactor: added GameManager

This commit is contained in:
Vova
2023-12-11 11:53:00 +02:00
parent 05bf8484f5
commit ea59babf93
23 changed files with 162 additions and 643 deletions
+57
View File
@@ -0,0 +1,57 @@
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();
}
}
}