// Use this for initialization void Start() { if (MainMenuManager.IsContinue) { DungeLikeCurrentGameData = BinarySaver.LoadCurrentGameData(); Level = DungeLikeCurrentGameData.Level; } Initialize(); }
internal void SaveCurrentGameData() { DungeLikeCurrentGameData = new DungeLikeCurrentGameData(); DungeLikeCurrentGameData.PlayerHealth = Player.Health.Value; DungeLikeCurrentGameData.PlayerMana = Player.Mana.Value; DungeLikeCurrentGameData.PlayerAttack = Player.Attack.Value; DungeLikeCurrentGameData.Level = Level; DungeLikeCurrentGameData.Gold = Player.Gold.Value; BinarySaver.SaveData(DungeLikeCurrentGameData); }
public static void SaveData(DungeLikeCurrentGameData data) { string folderPath = Path.Combine(Application.persistentDataPath, currentGameFolderName); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string filePath = Path.Combine(folderPath, currentGameFolderName + fileExtension); var binaryFormatter = new BinaryFormatter(); using (FileStream fileStream = File.Open(filePath, FileMode.OpenOrCreate)) { binaryFormatter.Serialize(fileStream, data); } }