public static LevelStatistic load(int level) { GameStatistics stats = GameStatistics.load(); int tempLevel = level; LevelStatistic found = stats.levelStats.Find(p => p.level == tempLevel); found = found != null ? found : new LevelStatistic { level = tempLevel }; found.collectedCoins = stats.collectedCoins; return(found); }
public void save() { GameStatistics stats = GameStatistics.load(); LevelStatistic found = stats.levelStats.Find(p => p.level == level); if (found != null) { stats.levelStats.Remove(found); } stats.levelStats.Add(this); stats.collectedCoins = collectedCoins; stats.save(); }
void Awake() { musicSource = gameObject.AddComponent <AudioSource>(); musicSource.clip = music; musicSource.loop = true; if (PlayerPrefs.GetInt("music", 1) == 1) { musicSource.Play(); } GameStatistics gameStats = GameStatistics.load(); coins = gameStats.collectedCoins; current = this; }
public void save() { Debug.Log("Level stats = " + JsonUtility.ToJson(this)); GameStatistics stats = GameStatistics.load(); LevelStatsistics found = stats.levelStats.Find(p => p.level == level); if (found != null) { stats.levelStats.Remove(found); } stats.levelStats.Add(this); stats.collectedCoins = collectedCoins; stats.save(); }