using System.Collections;
using System.Collections.Generic;
using UnityEditorInternal;
using UnityEngine;

public class GameManager : MonoBehaviour
{
    
    private static GameManager instance;
    public static GameManager Instance { get { return instance; } }

    private void Awake()
    {
        if (Instance == null)
            instance = this;
        else if (Instance == this)
            Destroy(gameObject);
    }

    private void Start()
    {
        GlobalEventManager.onCaptureFlag += flagCaptured;
        GlobalEventManager.onTimeLeft += timeOut;
    }

    private void Update()
    {
        
    }

    private void flagCaptured(Team team)
    {
        switch(team)
        {
            case Team.Attackers:
                Debug.Log("Attackers Win");
                break;
            case Team.Defenders:
                Debug.Log("Defenders Win");
                break;
            default:
                Debug.LogError("Unexpected Team");
                break;
        }
    }

    private void timeOut()
    {
        Debug.Log("Time is out");
    }

    private void OnDestroy()
    {
        GlobalEventManager.onCaptureFlag -= flagCaptured;
        GlobalEventManager.onTimeLeft -= timeOut;
    }
}
