using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour
{
    #region singleton

    public static GameManager Instance;

    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(transform);
        }
        else
            Destroy(gameObject);
    }

    #endregion

    public int countdownValue = 5;

    public void loadLevel1()
    {
        StartCoroutine(countdown("Level1"));
    }

    IEnumerator countdown(string levelName)
    {
        for (int i = countdownValue; i > 0; i--)
        {
            Debug.Log(i);
            yield return new WaitForSeconds(1f);
        }
        SceneManager.LoadScene(levelName);
    }

    public void loadLevel2()
    {
        StartCoroutine(countdown("Level2"));
    }

    public void loadLevel3()
    {
        SceneManager.LoadScene("Level3");
    }

    public void loadIntroduction()
    {
        SceneManager.LoadScene("Introduction");
    }

    public void exit()
    {
        Application.Quit();
    }
}
