/// <summary> /// Function that will manage the close of the app, saving the player's current status. /// </summary> private void OnApplicationQuit() { // Update _currentPlayerData if (GetInstance()._challengeWaiting) { GetInstance()._currentPlayerData._dateForNextChallenge = (int)(ConvertDateToSecond() + GetInstance()._timeChallengeWait); } // Save player information LoadingFiles.SavePlayerData(GetInstance()._currentPlayerData); }
/// <summary> /// Checks if the app has the focus and reloads all the info about the /// player and the times in case it's needed. /// </summary> /// <param name="focus"></param> private void OnApplicationFocus(bool focus) { isPaused = !focus; if (focus) { // Get Player information and store it GetInstance()._currentPlayerData = LoadingFiles.ReadPlayerData(GetInstance()._maxDifficulty); // Set the time waiting for challenge info SetTimeForChallenge(); } else { // Update _currentPlayerData if (GetInstance()._challengeWaiting) { GetInstance()._currentPlayerData._dateForNextChallenge = (int)(ConvertDateToSecond() + GetInstance()._timeChallengeWait); } // Save player information LoadingFiles.SavePlayerData(GetInstance()._currentPlayerData); } }
private void OnApplicationQuit() { LoadingFiles.SavePlayerData(currentPlayerData); }