using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; public static class DataManager { public static int Level { get { return PlayerPrefs.GetInt("Level"); } set { PlayerPrefs.SetInt("Level",value); } } public static int chapter { get { return PlayerPrefs.GetInt("chapter"); } set { PlayerPrefs.SetInt("chapter",value); } } public static bool chapterLock(int id) { return PlayerPrefs.GetInt("chapterUnLock"+id)==1; } public static void chapterLock(int id, bool bo) { PlayerPrefs.SetInt("chapterUnLock"+id,bo?1:0); } private static Dictionary _directory=new Dictionary(); public static bool LevelOpen(int id) { if (_directory.TryGetValue(id, out var open)) return open; var bo = PlayerPrefs.GetInt(id.ToString())==1; _directory.Add(id,bo); return _directory[id]; } public static void SetLevelOpen(int id,bool bo) { _directory[id] = bo; PlayerPrefs.SetInt(id.ToString(),bo?1:0); } }