void Start() { sumTime = 0.0f; currentItem = 0; trueLearnerFlag = 0; achievementsObject.resetAchievements(ach0, ach1, ach2, ach3, ach4, ach5, ach6, ach7, ach8, ach9); //Checks whether file exists and loads the file. Else creates a new blank file. if (saveSystemTwo.loadFileTwo() == null) { //create initial blank file saveSystemTwo.saveFileTwo(this); Debug.Log("No time file detected"); sumTime = 0.0f; startTimeOfLearning = elapsedTimeOfLearning = 0.0f; } else { //open old file Debug.Log("Time file detected"); timeFile data = saveSystemTwo.loadFileTwo(); totalTimeOfLearning = data.getTotalTimeLearning_sav(); chaptersReadCount = data.getChaptersReadCount_sav(); achievementsArray = data.getAchievementsArray_sav(); } }
public static void saveFileTwo(monitorActivity MA) { BinaryFormatter formatter = new BinaryFormatter(); string savePath = Application.persistentDataPath + "/timeFILE.txt"; FileStream stream = new FileStream(savePath, FileMode.Create); timeFile timeData = new timeFile(MA); formatter.Serialize(stream, timeData); stream.Close(); }
public void onClickAchievementsButton() { timeFile data = saveSystemTwo.loadFileTwo(); totalTimeOfLearning = data.getTotalTimeLearning_sav(); chaptersReadCount = data.getChaptersReadCount_sav(); achievementsObject.loadAchievements(); Debug.Log("File loaded!"); achievementsObject.achievementsUnlocker(ach0, ach1, ach2, ach3, ach4, ach5, ach6, ach7, ach8, ach9); }
public static timeFile loadFileTwo() { string savePath = Application.persistentDataPath + "/timeFILE.txt"; if (File.Exists(savePath)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(savePath, FileMode.Open); timeFile timeData = formatter.Deserialize(stream) as timeFile; stream.Close(); return(timeData); } else { Debug.LogError("File not found at " + savePath); return(null); } }