70 lines
1.5 KiB
C#
70 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private CameraSystem _cameraSystem;
|
|
[SerializeField]
|
|
private UISystem _uiSystem;
|
|
|
|
|
|
private bool _isPause;
|
|
private InputSystem _inputSystem;
|
|
private SceneManager _sceneManager;
|
|
private TimeSystem _timeSystem;
|
|
private InGameMouseHandler _gameMouseHandler;
|
|
|
|
public InputSystem Input => _inputSystem;
|
|
public SceneManager Scene => _sceneManager;
|
|
public TimeSystem Time => _timeSystem;
|
|
public UISystem UI => _uiSystem;
|
|
|
|
public CameraSystem Camera => _cameraSystem;
|
|
|
|
public static GameManager Instance { get; private set; }
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
|
|
_inputSystem = new InputSystem();
|
|
_sceneManager = new SceneManager();
|
|
_timeSystem = new TimeSystem();
|
|
_gameMouseHandler = new InGameMouseHandler(_cameraSystem.MainCamera);
|
|
}
|
|
else
|
|
Destroy(gameObject);
|
|
}
|
|
private void OnEnable()
|
|
{
|
|
_inputSystem.Enable();
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
_gameMouseHandler.Dispose();
|
|
_inputSystem.Disable();
|
|
}
|
|
|
|
public void Pause()
|
|
{
|
|
_isPause = true;
|
|
}
|
|
|
|
internal void Resume()
|
|
{
|
|
_isPause = false;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!_isPause)
|
|
{
|
|
_gameMouseHandler.Update();
|
|
_timeSystem.UpdateTime();
|
|
}
|
|
}
|
|
}
|