problèmes : - mon code et l'arrangement des fichiers avait besoin d'un peu de tidy up - les tiles qui n'étaient pas des LevelTile ne loadaient pas solution : - rangé un peu + respecté structure une classe - un fichier - tenté un build pour voir si tout roulait comme il faut, ce qui m'a porté à ajouter des directives de preprocessing et à bouger les custom inspectors dans le dossier Editor. - ajouté une représentation simple des tuiles non-LevelTile dans la sauvegarde.
31 lines
848 B
C#
31 lines
848 B
C#
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();
|
|
}
|
|
} |