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

public class Scene_Manager : MonoBehaviour
{

    public Animator transition;

    public void loadScene(SceneField scene)
    {
        StartCoroutine(LoadScene(scene, 0.0f));
    }

    public void loadScene(SceneField scene, float delay)
    {
        StartCoroutine(LoadScene(scene, delay));
    }

    public void loadSceneWithTransition(SceneField scene, float delay)
    {
        StartCoroutine(LoadSceneWithTransition(scene, delay));
    }

    public void loadMainMenu()
    {
        StartCoroutine(LoadMainMenu(0));
    }

    public void loadMainMenuWithTransition()
    {
        StartCoroutine(LoadMainMenuWithTransition(0.5f));
    }

    IEnumerator LoadScene(SceneField scene, float delay)
    {
        yield return new WaitForSeconds(delay);
        SceneManager.LoadScene(scene);
    }

    IEnumerator LoadSceneWithTransition(SceneField scene, float delay)
    {
        transition.SetTrigger("close");
        yield return new WaitForSeconds(delay);
        SceneManager.LoadScene(scene);
    }

    IEnumerator LoadMainMenu(float delay)
    {
        yield return new WaitForSeconds(delay);
        SceneManager.LoadScene("MainMenu");

    }

    IEnumerator LoadMainMenuWithTransition(float delay)
    {
        transition.SetTrigger("close");
        yield return new WaitForSeconds(delay);
        SceneManager.LoadScene("MainMenu");

    }

}
