public LevelBestScore ReadLevelBestScoreData(int pIndex) { _selectedLevelIndex = pIndex; _selectedLevelBestScore = null; string lFilePath = getBestScoreLevelLocalFilePath(_selectedLevelIndex); if (File.Exists(lFilePath)) { string lJsonString = File.ReadAllText(lFilePath); _selectedLevelBestScore = JsonUtility.FromJson <LevelBestScore>(lJsonString); } return(_selectedLevelBestScore); }
public void UpdateLevelBestScoreData(int pMinutes, int pSeconds) { if (_selectedLevelBestScore != null) { _selectedLevelBestScore.TotalPlaysCount++; if (pMinutes * 60 + pSeconds < _selectedLevelBestScore.Minutes * 60 + _selectedLevelBestScore.Seconds) { _selectedLevelBestScore.Minutes = pMinutes; _selectedLevelBestScore.Seconds = pSeconds; } } else { _selectedLevelBestScore = new LevelBestScore(pMinutes, pSeconds, 1); _completedLevelCount++; PlayerPrefs.SetInt(COMPLETED_LEVEL_KEY, _completedLevelCount); } File.WriteAllText(getBestScoreLevelLocalFilePath(_selectedLevelIndex), JsonUtility.ToJson(_selectedLevelBestScore)); }
public void ShowLevelBestScoreInfo(LevelBestScore pBestScore) { _bestScoreText.text = pBestScore != null?formatLevelBestScoreText(pBestScore) : NO_BEST_SCORE_TEXT; }
private string formatLevelBestScoreText(LevelBestScore pBestScore) { return("Best time is " + formatTimeText(pBestScore.Minutes, pBestScore.Seconds) + " of the total " + pBestScore.TotalPlaysCount + " number of scores."); }