using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class GameModeEvents : MonoBehaviour
{
    [Header("Reference")]
    [SerializeField]
    private GameModeReference Reference;

    [Header("Events")]
    public UnityEvent OnRoundStart = new UnityEvent();
    public UnityEvent OnPlayersMoved = new UnityEvent();
    public UnityEvent OnRoundEnd = new UnityEvent();
    public UnityEvent OnGameOver = new UnityEvent();


    private void OnEnable()
    {
        Reference.Value.RoundStartEvent += RoundStart;
        Reference.Value.AllPlayersMovedEvent += PlayersMoved;
        Reference.Value.RoundEndEvent += RoundEnd;
        Reference.Value.OnGameOverEvent += GameOver;
    }

    private void OnDisable()
    {
        Reference.Value.RoundStartEvent -= RoundStart;
        Reference.Value.AllPlayersMovedEvent -= PlayersMoved;
        Reference.Value.RoundEndEvent -= RoundEnd;
        Reference.Value.OnGameOverEvent -= GameOver;
    }


    private void RoundStart()
    {
        OnRoundStart.Invoke();
    }

    private void PlayersMoved()
    {
        OnPlayersMoved.Invoke();
    }

    private void RoundEnd()
    {
        OnRoundEnd.Invoke();
    }
    private void GameOver()
    {
        OnGameOver.Invoke();
    }
}
