public void OnLevelFinished(float timeTaken) { if (pg != null) { ClickedRetryButton(false); playerStats.listOfObjects.Clear(); } else { string levelName = gameObject.scene.name; string[] levelIdentity = levelName.Split('.'); int currentChapterIndex = int.Parse(levelIdentity[0]); int currentLevelIndex = int.Parse(levelIdentity[1]); float prevBestTime = playerStats.chaptersList[currentChapterIndex].LevelsInChapter[currentLevelIndex].PersonalBestTime; playerStats.levelCompletionData = new PlayerStatistics.LevelCompletionData(currentChapterIndex, currentLevelIndex, coinsInScene, currentCoinsAcquired, timeTaken, prevBestTime); UpdateAndUnlockNextLevel(currentChapterIndex, currentLevelIndex, timeTaken); if (ShowInterstitialAd(currentChapterIndex, currentLevelIndex)) { adMobClass.ShowInterstitialAd(); } SceneManager.LoadScene("Level Complete"); } LoadSaveStats.SavePlayerData(playerStats.tasksList, playerStats.chaptersList, playerStats.upgradesList, playerStats.firstActiveTaskIndex, playerStats.secondActiveTaskIndex, playerStats.tasksCompleted, playerStats.highestChapter, playerStats.highestLevel, playerStats.playerCoins, playerStats.musicVolume, playerStats.sfxVolume); }
private void Start() { PlayerData playerData = LoadSaveStats.LoadPlayerData(); if (playerData != null) { PersistentInformation.CurrentChapter = playerData.currentChapter; playerCoins = playerData.playerCoins; RestoreTasksData(playerData.tasksList, playerData.firstActiveTaskIndex, playerData.secondActiveTaskIndex, playerData.tasksCompleted); RestoreUpgradesData(playerData.upgradesList); RestoreChaptersData(playerData.chaptersList); RestoreOtherData(playerData.musicVolume, playerData.sfxVolume, playerData.highestChapter, playerData.highestLevel); } else { PersistentInformation.CurrentChapter = 0; playerCoins = 1000; AddTasks(); AddUpgrades(); AddChapters(); } DumpColors(); playerStatsLoaded = true; PersistentInformation.timerForInfinitelevel = 0f; }