コード例 #1
0
    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);
    }