public void Awake() { InitVariables(); Directory.CreateDirectory(_savePathBase); if (File.Exists(_globalSavePath)) { using (var fs = File.OpenRead(_globalSavePath)) _globalSave = ReadSave <GlobalSave>(fs); } else { ResetGlobalSave(); } var regex = new Regex("sav([0-9]+).nsav"); foreach (var name in Directory.GetFiles(_savePathBase, "sav*.nsav")) { var result = regex.Match(name); if (result.Groups.Count > 1) { int id; if (int.TryParse(result.Groups[1].Value, out id)) { UsedSaveSlots.Add(id); } } } Debug.Log("CheckpointManager Initialized"); }
/// <summary> /// Reset the global save file to clear all progress. /// Note that all the other save files will be invalid. /// </summary> public void ResetGlobalSave() { using (var fs = File.OpenWrite(_globalSavePath)) WriteSave(_globalSave = new GlobalSave(), fs); }