38 lines
757 B
C#
38 lines
757 B
C#
2 months ago
|
using UnityEngine;
|
||
|
using System;
|
||
|
|
||
|
public class GameStateManager : MonoBehaviour
|
||
|
{
|
||
|
public static GameStateManager Instance { get; private set; }
|
||
|
|
||
|
public event Action<CursorState> OnStateChanged;
|
||
|
|
||
|
private CursorState currentState = CursorState.Default;
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
if (Instance == null)
|
||
|
{
|
||
|
Instance = this;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Destroy(gameObject); // Prevent duplicates
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void ChangeState(CursorState newState)
|
||
|
{
|
||
|
if (currentState != newState)
|
||
|
{
|
||
|
currentState = newState;
|
||
|
OnStateChanged?.Invoke(newState);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public CursorState GetCurrentState()
|
||
|
{
|
||
|
return currentState;
|
||
|
}
|
||
|
}
|