Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarthel-fr committed Oct 29, 2013
2 parents 3df8581 + 6d65b10 commit 0c810db
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import fr.tvbarthel.games.chasewhisply.google.BaseGameActivity;
import fr.tvbarthel.games.chasewhisply.mechanics.informations.GameInformation;
import fr.tvbarthel.games.chasewhisply.mechanics.informations.GameInformationStandard;
import fr.tvbarthel.games.chasewhisply.mechanics.informations.GameInformationTime;
import fr.tvbarthel.games.chasewhisply.model.PlayerProfile;
import fr.tvbarthel.games.chasewhisply.model.mode.GameMode;
import fr.tvbarthel.games.chasewhisply.model.mode.GameModeFactory;
Expand Down Expand Up @@ -237,12 +238,19 @@ public void onHomeRequested() {
public void onUpdateAchievements(final GameInformationStandard gameInformation, final PlayerProfile playerProfile) {
final GamesClient gamesClient = getGamesClient();
if (gamesClient.isConnected()) {
final int score = gameInformation.getCurrentScore();
final long exp = playerProfile.getLevelInformation().getTotalExpEarned();
final GameMode gameMode = gameInformation.getGameMode();
final Weapon weapon = gameInformation.getWeapon();
final int numberOfLoots = gameInformation.getNumberOfLoots();

//TODO find a better way to retrieve score
long score = gameInformation.getCurrentScore();
final int gameType = gameInformation.getGameMode().getType();
if (gameType == GameModeFactory.GAME_TYPE_DEATH_TO_THE_KING
|| gameType == GameModeFactory.GAME_TYPE_TWENTY_IN_A_ROW) {
score = ((GameInformationTime) gameInformation).getPlayingTime();
}

//Submit score for the played game mode
final int leaderBoardStringId = gameMode.getLeaderboardStringId();
if (score > 0 && leaderBoardStringId != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class PlayerProfile {
private static final String KEY_RANK_SURVIVAL = "keyRankSurvival";
private static final String KEY_RANK_DEATH_TO_THE_KING = "keyRankDeathToTheKing";
private static final String KEY_RANK_MEMORIZE = "keyRankMemorize";
private static final String KEY_RANK_TWENTY_IN_A_ROW = "keyRankTwentyInARow";

private SharedPreferences mSharedPreferences;
private SharedPreferences.Editor mEditor;
Expand Down Expand Up @@ -297,6 +298,9 @@ public int getRankByGameMode(GameMode g) {
case GameModeFactory.GAME_TYPE_MEMORIZE:
rank = mSharedPreferences.getInt(KEY_RANK_MEMORIZE, 0);
break;
case GameModeFactory.GAME_TYPE_TWENTY_IN_A_ROW:
rank = mSharedPreferences.getInt(KEY_RANK_TWENTY_IN_A_ROW, 0);
break;
default:
rank = 0;
break;
Expand Down Expand Up @@ -334,6 +338,11 @@ public void setRankByGameMode(GameMode g, int rank) {
mEditor.putInt(KEY_RANK_MEMORIZE, rank);
}
break;
case GameModeFactory.GAME_TYPE_TWENTY_IN_A_ROW:
if (rank > mSharedPreferences.getInt(KEY_RANK_TWENTY_IN_A_ROW, 0)) {
mEditor.putInt(KEY_RANK_TWENTY_IN_A_ROW, rank);
}
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ public static GameMode createRemainingTimeGame(int level) {
g.setTitle(R.string.game_mode_title_sprint);
break;

case 2:
g = new GameMode();
g.setImage(R.drawable.ic_icon_time_based_game_60_s);
g.setLeaderboardStringId(R.string.leaderboard_60_seconds);
g.setLeaderboardDescriptionStringId(R.string.leaderboard_chooser_time_limited_level_2_description);
break;

case 3:
g = new GameModeMarathon();
g.setImage(R.drawable.ic_icon_time_based_game_90_s);
Expand Down
18 changes: 10 additions & 8 deletions ChaseWhisply/src/main/res/layout-land/fragment_score.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@
android:layout_marginBottom="@dimen/default_vertical_margin"
android:layout_marginRight="@dimen/default_horizontal_margin"
android:id="@+id/linearLayout2"
android:layout_centerVertical="true">
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/linear_layout_buttons">

<TextView
android:id="@+id/textView2"
Expand All @@ -252,7 +254,7 @@
android:textSize="@dimen/home_text_size"/>

<LinearLayout
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/default_horizontal_margin"
android:orientation="horizontal">
Expand Down Expand Up @@ -312,9 +314,9 @@


<LinearLayout
android:layout_width="70dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="@dimen/half_padding"
android:layout_marginLeft="@dimen/default_horizontal_margin"
android:orientation="vertical">

<TextView
Expand Down Expand Up @@ -368,15 +370,15 @@
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:id="@+id/linear_layout_buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/default_horizontal_margin"
android:orientation="vertical"
android:baselineAligned="false"
android:layout_alignParentRight="false"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/linearLayout2">
android:layout_centerVertical="true">

<Button
android:id="@+id/score_button_skip"
Expand Down
16 changes: 8 additions & 8 deletions ChaseWhisply/src/main/res/layout/fragment_score.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
android:textSize="@dimen/home_text_size"/>

<LinearLayout
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/default_horizontal_margin"
android:orientation="horizontal">
Expand Down Expand Up @@ -293,54 +293,54 @@


<LinearLayout
android:layout_width="70dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="@dimen/half_padding"
android:layout_marginLeft="@dimen/default_horizontal_margin"
android:orientation="vertical">

<TextView
android:id="@+id/numberOfTargetsKilled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="@dimen/half_padding"
android:text="@string/integer_zero"
android:layout_gravity="right"
android:textAppearance="@android:style/TextAppearance.Medium"/>

<TextView
android:id="@+id/numberOfBulletsFired"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="@dimen/half_padding"
android:text="@string/integer_zero"
android:layout_gravity="right"
android:textAppearance="@android:style/TextAppearance.Medium"/>

<TextView
android:id="@+id/maxCombo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="@dimen/half_padding"
android:text="@string/integer_zero"
android:layout_gravity="right"
android:textAppearance="@android:style/TextAppearance.Medium"/>

<TextView
android:id="@+id/expEarned"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="@dimen/half_padding"
android:text="@string/integer_zero"
android:layout_gravity="right"
android:textAppearance="@android:style/TextAppearance.Medium"/>

<TextView
android:id="@+id/finalScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="@dimen/default_padding"
android:text="@string/integer_zero"
android:layout_gravity="right"
android:textAppearance="@android:style/TextAppearance.Large"/>

</LinearLayout>
Expand Down

0 comments on commit 0c810db

Please sign in to comment.