/// <summary> /// Marks a given chaos void as cleared /// </summary> /// <param name="chaosVoid">Reference to the chaos void level to load</param> public void ClearChaosVoid() { if (activeLevel is null) { activeLevel = Array.Find(chaosVoids, (level) => level.scene.name == SceneManager.GetActiveScene().name); if (activeLevel is null) { Debug.Log("Unable to find chaos void."); return; } } activeLevel.cleared = true; numClearedLevels++; }
/// <summary> /// Return a number representing how complete the game is /// </summary> /// <param name="slot">Slot to check</param> public float GetCompletion(int slot) { if (!Directory.Exists(Application.persistentDataPath + "/saves/" + slot + "/levels")) { return(0); } float percentComplete = 0; BinaryFormatter binaryFormatter = new BinaryFormatter(); for (int i = 0; i < chaosVoids.Length; i++) { FileStream file = File.Open(Application.persistentDataPath + "/saves/" + slot + "/levels/level" + i + "_save", FileMode.Open); ChaosVoid chaosVoid = ScriptableObject.CreateInstance <ChaosVoid>(); JsonUtility.FromJsonOverwrite((string)binaryFormatter.Deserialize(file), chaosVoid); if (chaosVoid.cleared) { percentComplete += 1f / chaosVoids.Length; } file.Close(); } return(percentComplete); }
/// <summary> /// Starts a given chaos void /// </summary> /// <param name="chaosVoid">Reference to the chaos void level to load</param> public void StartChaosVoid(ChaosVoid chaosVoid) { StartCoroutine(LoadYourAsyncScene(chaosVoid.scene.name, SceneType.Level)); chaosVoid.Initialize(); activeLevel = chaosVoid; }