using UnityEngine;
using UnityEngine.SceneManagement;

public class levelChooser : MonoBehaviour
{
    private static int index = 0;
    public static string[] scenes = {"Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6", "Level 7", "Level 8", "Level 9", "Level 10",
                                     "Level 11", "Level 12", "Level 13", "Level 14", "Level 15", "Level 16", "Level 17", "Level 18", "Level 19", "Level 20",
                                     "Level 21", "Level 22", "Level 23", "Level 24", "Level 25", "Level 26", "Level 27", "Level 28", "Level 29", "Level 30"};
    

    void Move(int change)
    {
        index = Mathf.Clamp(index + change, 0, scenes.Length - 1);
    }

    public void AddOne()
    {
        Move(+1);
    }

    public void RemoveOne()
    {
        Move(-1);
    }

    public static void ChooseLevel(int level)
    {
        index = Mathf.Clamp(level-1, 0, scenes.Length - 1); ;
        Debug.Log(index);
        SceneManager.LoadScene(sceneName: scenes[index]);
    }

    public static int GetIndex() 
    {
        return index;
    }

    public static void NextLevel()
    {
        index += 1;
        if (index < scenes.Length)
            SceneManager.LoadScene(sceneName: scenes[index]);
        else
        {
            index = 0;
            SceneManager.LoadScene(sceneName: "Menu");
        }
    }
}
