45 lines
965 B
C#
45 lines
965 B
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
[SerializeField] private PlayerInput _controls;
|
|
[SerializeField, ReadOnly] private GameState _state;
|
|
|
|
public static GameManager Instance { get; private set; }
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Instance = this;
|
|
_state = GameState.InGame;
|
|
}
|
|
}
|
|
|
|
public void TriggerGameOver(int dimensionID)
|
|
{
|
|
if (_state == GameState.Loss) return;
|
|
|
|
// Stop controls
|
|
_controls.SwitchCurrentActionMap("UI");
|
|
|
|
// Show Game Over Message
|
|
Debug.Log("Game Over: Dimension " + dimensionID + " has been destroyed");
|
|
|
|
// Show Options (Return to Menu / Retry)
|
|
_state = GameState.Loss;
|
|
}
|
|
|
|
}
|
|
|
|
public enum GameState
|
|
{
|
|
InGame,
|
|
Loss,
|
|
} |