using UnityEngine;
using GatherAndDefend.LevelEditor;

public class LevelManagerScript : MonoBehaviour
{
    public Level firstLevel;
    private static LevelManagerScript _instance; 

    void Awake()
    {
        //we don't want to ever have two LevelManagerScript at the same time in the game.
        //We prevent that by erasing any instances that are not registered as our main instance.
        if (!_instance)
        {
            _instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);
        if (!firstLevel) throw new System.Exception("there is no first level set in the level manager script");
        LevelManager.Instance.LoadLevel(firstLevel, true);
    }
    void Update()
    {
        LevelManager.Instance.UpdateLevel();
    }
}