27 lines
769 B
C#
27 lines
769 B
C#
using UnityEngine;
|
|
using GatherAndDefend.LevelEditor;
|
|
|
|
public class LevelManagerScript : SingletonBehaviour<LevelManagerScript>
|
|
{
|
|
public Level firstLevel;
|
|
private void Start()
|
|
{
|
|
DontDestroyOnLoad(gameObject);
|
|
if (!firstLevel) throw new System.Exception("there is no first level set in the level manager script");
|
|
|
|
int levelToLoadFromWorldMap = PlayerPrefs.GetInt("LevelToLoad", -1);
|
|
if (levelToLoadFromWorldMap != -1)
|
|
{
|
|
string lvlName = $"Level{levelToLoadFromWorldMap}";
|
|
LevelManager.Instance.LoadLevel(lvlName, true);
|
|
return;
|
|
}
|
|
|
|
LevelManager.Instance.LoadLevel(firstLevel, true);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
LevelManager.Instance.UpdateLevel();
|
|
}
|
|
} |