public void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/CompletionData.dat", FileMode.OpenOrCreate); LevelDataContainer gameData = new LevelDataContainer(); gameData.Data.LevelData = _levelCompletion; bf.Serialize(file, gameData); file.Close(); }
public void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/LevelData.dat"); LevelDataContainer container = new LevelDataContainer(); container.hp = HP; container.ac = AC; container.damage = Damage; bf.Serialize(file, container); file.Close(); }
public void Save() { var bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/LevelData.dat"); var container = new LevelDataContainer(); container.hp = HP; container.ac = AC; container.damage = Damage; bf.Serialize(file, container); file.Close(); }
public void Load() { if (File.Exists(Application.persistentDataPath + "/LevelData.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/LevelData.dat", FileMode.Open); LevelDataContainer container = (LevelDataContainer)bf.Deserialize(file); file.Close(); HP = container.hp; AC = container.ac; Damage = container.damage; } }
public void ClearCompletionData() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/CompletionData.dat", FileMode.Create); LevelDataContainer blankGameData = new LevelDataContainer(); blankGameData.Data.LevelData = new LevelDataContainer.LevelType[NumLevels]; bf.Serialize(file, blankGameData); file.Close(); Load(); Debug.Log("Level Data Cleared"); }
private void OnGUI() { levelDataContainer = (LevelDataContainer)Selection.activeObject; GUILayout.Label("Select the level data container and hit Clean"); if (GUILayout.Button("Clean")) { foreach (Level level in levelDataContainer.levels) { level.isCompleted = false; level.completionTime = 0; level.ghostRun = new Vector3[0]; } } }