using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class LevelLoader : MonoBehaviour
{
    public Button[] LevelButtons = null;

    // Start is called before the first frame update
    void Start()
    {
        for (int i = 0; i < LevelButtons.Length; i++)
        {

            LevelButtons[i].interactable = i <= HighestLevelCompleted;
        }
    }

    private int HighestLevelCompleted
    {
        get
        {
            for (int i = 0; i < GameState.Scores.Length; i++)
            {
                if (GameState.Scores[i] == 0)
                    return i;
            }
            return 99;
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void LevelButtonPressed(int index)
    {
        GameState.LevelToPlay = index;
        UnityEngine.SceneManagement.SceneManager.LoadScene("GameScene");
    }
}
