123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class LevelManager : MonoBehaviour
- {
- public static LevelManager Instance;
- public List<Level> ListLevels;
- public Level CurLevel;
- public const int STAGE_LEVEL = 3;
- void Start()
- {
- Instance = this;
- SetLevel(Core.Instance.PlayerData.Stage);
- }
- public void SetLevel(int indexStage)
- {
-
- int indexLevel = Mathf.CeilToInt(indexStage / STAGE_LEVEL);
- UIManager.Instance.StageLabel.text = "Level " + (Core.Instance.PlayerData.Stage+1).ToString();
- for(var i=0; i< ListLevels.Count;i++)
- {
- ListLevels[i].gameObject.SetActive(false);
- }
- ListLevels[indexLevel].gameObject.SetActive(true);
- ListLevels[indexLevel].Init();
- CurLevel = ListLevels[indexLevel];
- ListLevels[indexLevel].ResetLever();
- }
- public void NextLevel()
- {
-
- if (Core.Instance.PlayerData.Stage<= ListLevels.Count * STAGE_LEVEL)
- {
- //var curLevel = Mathf.CeilToInt(Core.Instance.PlayerData.Stage / STAGE_LEVEL);
- SetLevel(Core.Instance.PlayerData.Stage);
-
- }
- else
- {
- UIManager.Instance.GameEnd();
- }
- //for (var i = 0; i < ListLevels.Count; i++)
- //{
- // ListLevels[i].gameObject.SetActive(false);
- //}
- //ListLevels[indexLevel].gameObject.SetActive(true);
- //ListLevels[indexLevel].Init();
- }
- }
|