public void saveLocalScore() { int score = game.getScore(); if (score > game.getHighScore()) { game.setHighScore(score); ScoreManager.saveHighScore(game, this); } }
public void processLeaderBoard() { Game.Mode gameMode = game.getMode(); if (gameMode == Game.Mode.Standard || gameMode == Game.Mode.Survival) { Games.Leaderboards.submitScore( mGoogleApiClient, Constants.leaderboards[Game.intForMode(gameMode)][ Game.intForDifficulty(game.getDifficulty())], game.getScore()); } }
private void startGame() { Intent intent; if (game.getMode() == Game.Mode.Standard) { intent = new Intent(this, StandardActivity.class); } else if (game.getMode() == Game.Mode.Survival) { intent = new Intent(this, SurvivalActivity.class); startActivity(intent); } else { intent = new Intent(this, PracticeActivity.class); } intent.putExtra(Game.EXTRA_KEY, game.reset()); startActivity(intent); finish(); }
public void processAchievements() { int score = game.getScore(); if (score > 0) { Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_boom); // Score level achievements Games.Achievements.increment( mGoogleApiClient, Constants.achievement_just_getting_started, score); Games.Achievements.increment( mGoogleApiClient, Constants.achievement_established_starter, score); Games.Achievements.increment(mGoogleApiClient, Constants.achievement_seasoned_pro, score); Games.Achievements.increment(mGoogleApiClient, Constants.achievement_grizzly_veteran, score); Games.Achievements.increment(mGoogleApiClient, Constants.achievement_gridiron_legend, score); Games.Achievements.increment( mGoogleApiClient, Constants.achievement_never_gonna_give_your_up, score); } if (controller.hadWrongAnswer()) { Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_oops); } if (controller.getBestStreak() >= 3) { Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_tictactoe); } if (controller.getLongestWrongStreak() >= 3) { Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_tictacouch); } if (controller.getStartStreak() >= 10) { Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_jumping_the_snap_count); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.result_view); ButterKnife.bind(this); game = getIntent().getParcelableExtra(Game.EXTRA_KEY); resultScore.setText(getString(R.string.scoreDisplay, game.getScore())); controller = GameController.getInstance(); saveLocalScore(); if (!BuildConfig.DEBUG) { if (mGoogleApiClient.isConnected()) { processAchievements(); processLeaderBoard(); postedGMSData = true; } } }