Files
the-peoples-messenger/Assets/Scripts/GlobalStateManager.cs
T

73 lines
1.5 KiB
C#

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Utils;
public class GlobalStateManager : Singleton<GlobalStateManager>
{
public int MenuIntended = 0;
public int LevelIntended;
public int HighestLevel;
public List<TextAsset> levels;
public TextAsset parlorPuzzles;
//aaaaa theres nicer syntax for this i think
protected override bool dontDestroyOnLoad()
{
return true;
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
HighestLevel = PlayerPrefs.GetInt("HighestLevel", 0);
}
// Update is called once per frame
void Update()
{
}
public void SetLevelCompleted()
{
if (LevelIntended == HighestLevel)
{
LevelIntended++;
HighestLevel++;
PlayerPrefs.SetInt("HighestLevel", HighestLevel);
PlayerPrefs.Save();
//Reload game scene to start next level??
SceneManager.LoadScene(1);
}
else
{
//playing old level so load level select
MenuIntended = 1;
SceneManager.LoadScene(0);
}
}
public void PlayNewestLevel()
{
LevelIntended = HighestLevel;
//load game scene
SceneManager.LoadScene(1);
}
public void LoadSpecificLevel(int level)
{
LevelIntended = level;
//load game scene
SceneManager.LoadScene(1);
}
}