Пример #1
0
    public void OnGameSucces()
    {
        cameraController.Play(.2f, false);
        AudioManager.instance.PlaySound("SuccesSound");
        StartCoroutine(WaitThenUnplay(2.2f, .2f));
        gameOver = true;
        succesTab.SetActive(true);
        uiTab.SetActive(false);
        highScoreDiamonds.text                    = string.Format("{0} / {1}", diamonds, totalDiamonds);
        highScoreSpecialDiamonds.text             = string.Format("{0} / {1}", specialDiamonds, totalSpecialDiamonds);
        SaveManager.Instance.data.diamonds       += diamonds;
        SaveManager.Instance.data.specialDiamond += specialDiamonds;
        AdsManager.Instance.canShowAd             = true;

        if (isEndlessLevel)
        {
            EndlessManager endless = FindObjectOfType <EndlessManager>();
            PlayGamesPlatform.Instance.LoadScores(
                GPGSIds.leaderboard_blitexs_endless,
                LeaderboardStart.PlayerCentered,
                1,
                LeaderboardCollection.Public,
                LeaderboardTimeSpan.AllTime,
                (LeaderboardScoreData data) =>
            {
                if (data.Valid)
                {
                    long total = data.PlayerScore.value + (long)endless.score;
                    PlayServices.AddScoreToLeaderBoard(GPGSIds.leaderboard_blitexs_endless, total);
                }
            });
        }

        if (SaveManager.Instance.data.completedLevels == 0)
        {
            //first level that is played
            PlayServices.UnlockAchievement(GPGSIds.achievement_first_level);
        }
        if (!isSnowLevel)
        {
            SaveManager.Instance.CompleteLevel(Manager.Instance.sceneIndex, false);

            if (SaveManager.Instance.data.completedLevels >= 15 && !SaveManager.Instance.data.hasUnlockedSnowTheme)
            {
                //player has completed 15 levels so now he unlocks snow theme
                print("Congrats u unlocked snow theme");
                PlayServices.UnlockAchievement(GPGSIds.achievement_unlocked_snow_theme);
                unlockedSnowTheme.SetActive(true);
                SaveManager.Instance.data.hasUnlockedSnowTheme = true;
                SaveManager.Instance.Save();
            }
        }

        else if (isSnowLevel)
        {
            print("It is a snow level and now calling complete level");
            SaveManager.Instance.CompleteLevel(Manager.Instance.sceneIndex, true);
        }

        PlayGamesPlatform.Instance.LoadScores(
            GPGSIds.leaderboard_blitexs_diamonds,
            LeaderboardStart.PlayerCentered,
            1,
            LeaderboardCollection.Public,
            LeaderboardTimeSpan.AllTime,
            (LeaderboardScoreData data) =>
        {
            if (data.Valid)
            {
                long total = data.PlayerScore.value + (long)diamonds;
                PlayServices.AddScoreToLeaderBoard(GPGSIds.leaderboard_blitexs_diamonds, total);
            }
        });

        PlayServices.IncrementAchievement(GPGSIds.achievement_100_diamonds, diamonds);
        PlayServices.IncrementAchievement(GPGSIds.achievement_1000_diamonds, diamonds);
        PlayServices.IncrementAchievement(GPGSIds.achievement_10_000_diamonds, diamonds);

        StartCoroutine(WaitThenDestroy(1.5f));
    }