Exemplo n.º 1
0
    private void EndGame()
    {
        Time.timeScale = 0f; //  Stop the game after the game has ended...

        switch (difficulty)
        {
        case 1:
            if (score > PlayerPrefs.GetFloat("easyHighScore", 0))
            {
                PlayerPrefs.SetFloat("easyHighScore", score);
                gameOverText.text = "HIGH SCORE:";
            }
            break;

        case 2:
            if (score > PlayerPrefs.GetFloat("normalHighScore", 0))
            {
                PlayerPrefs.SetFloat("normalHighScore", score);
                PlayGamesManager.AddScoreToLeaderboard(GPGSIds.leaderboard_global_high_score_normal, Convert.ToInt64(score));
                gameOverText.text = "HIGH SCORE:";
            }
            break;

        case 3:
            if (score > PlayerPrefs.GetFloat("hellHighScore", 0))
            {
                PlayerPrefs.SetFloat("hellHighScore", score);
                PlayGamesManager.AddScoreToLeaderboard(GPGSIds.leaderboard_global_high_score_hell, Convert.ToInt64(score));
                gameOverText.text = "HIGH SCORE:";
            }
            break;
        }
        gameOverScoreText.text = (score > 999999999999) ? "999999999999" : Convert.ToInt64(score).ToString("000000000000.##");
        gameOverUI.SetActive(true);
    }
 public void RestartGame()
 {
     PlayGamesManager.AddScoreToLeaderboard(GaryGravityResources.leaderboard_swifest_leaderboard, Counter);
     Counter = 0;
 }
Exemplo n.º 3
0
    public virtual void ProcessScores(bool isOnStart)
    {
        if (isOnStart)
        {
            //load scores from preferences to variables
            highScore      = SecurePlayerPrefs.GetInt("HighScore");
            levelHighScore = SecurePlayerPrefs.GetInt("HighScoreLvl" + currentLevelID.ToString());
            coinScore      = SecurePlayerPrefs.GetInt("CoinScore");
            //scoreText.text = score.ToString();
            //highScoreText.text = highScore.ToString();
            //coinCountText.text = "x " + coinScore.ToString();
        }
        else
        {
            if (score.Equals(highScore))
            {
                SecurePlayerPrefs.SetInt("HighScore", highScore);

                if (PlayGamesPlatform.Instance.IsAuthenticated())
                {
                    //send highScore to Google Play Games Overall HighScores leaderboard
                    PlayGamesManager.AddScoreToLeaderboard(GPGSIds.leaderboard_overall_high_scores, Convert.ToInt64(highScore));
                }
            }

            if ((score.Equals(levelHighScore)) && (currentLevelID != 0))//Leaderboard
            {
                SecurePlayerPrefs.SetInt("HighScoreLvl" + currentLevelID.ToString(), highScore);

                if (PlayGamesPlatform.Instance.IsAuthenticated())
                {
                    //send highScore to Google Play Games Level leaderboard
                    switch (currentLevelID)
                    {
                    case 3:
                        PlayGamesManager.AddScoreToLeaderboard(GPGSIds.leaderboard_level_1_high_scores, Convert.ToInt64(levelHighScore));
                        break;

                    case 4:
                        PlayGamesManager.AddScoreToLeaderboard(GPGSIds.leaderboard_level_2_high_scores, Convert.ToInt64(levelHighScore));
                        break;

                    case 5:
                        PlayGamesManager.AddScoreToLeaderboard(GPGSIds.leaderboard_level_3_high_scores, Convert.ToInt64(levelHighScore));
                        break;

                    case 6:
                        PlayGamesManager.AddScoreToLeaderboard(GPGSIds.leaderboard_level_4_high_scores, Convert.ToInt64(levelHighScore));
                        break;
                    }
                }
            }

            if (PlayGamesPlatform.Instance.IsAuthenticated())
            {
                switch (coinScore)
                {
                case 5:
                    PlayGamesManager.UnlockAchievement(GPGSIds.achievement_first_5_coins);
                    break;

                case 25:
                    PlayGamesManager.UnlockAchievement(GPGSIds.achievement_first_25_coins);
                    break;

                case 50:
                    PlayGamesManager.UnlockAchievement(GPGSIds.achievement_first_50_coins);
                    break;

                case 100:
                    PlayGamesManager.UnlockAchievement(GPGSIds.achievement_first_100_coins);
                    break;

                case 250:
                    PlayGamesManager.UnlockAchievement(GPGSIds.achievement_first_250_coins);
                    break;

                default:
                    break;
                }
            }


            SecurePlayerPrefs.SetInt("CoinScore", coinScore);
        }
    }