using UnityEngine;
using UnityEngine.Events;

public class GameStateController : MonoBehaviour, ISubscriberGameState
{
    public UnityEvent playing;
    public UnityEvent paused;
    public UnityEvent gameOver;

    private void Start()
    {
        subscribe();
    }

    public void notifyInput(EnumGameState state)
    {
        switch (state)
        {
            case EnumGameState.PLAYING:
                playing.Invoke();
                break;
            case EnumGameState.PAUSED:
                paused.Invoke();
                break;
            case EnumGameState.GAMEOVER:
                gameOver.Invoke();
                break;
            default:
                break;
        }
    }

    public void subscribe()
    {
        GameObject.FindGameObjectsWithTag("GameManager")[0].GetComponent<Game_Manager>().subscribe(gameObject);
    }
}
