Commit 70da7ce6 authored by Drahomír Karchňák's avatar Drahomír Karchňák

#328 Added text assets for ranks. Refactoring...

parent 997f551b
......@@ -168,5 +168,19 @@ user_consecutivelyallgames2stars_description=Za všechny hry po sobě na středn
user_consecutivelyallgames3stars=Detektivní šelma
user_consecutivelyallgames3stars_description=Za všechny hry po sobě na těžkou obtížnost a tři poháry
# <!-- Ranky -->
user_rank_promotion=Povýšení
user_rank_1=Zástupce zelenáče
user_rank_2=Zelenáč
user_rank_3=Čmuchal
user_rank_4=Pátral
user_rank_5=Vrchní pátral
user_rank_6=Inspektor
user_rank_7=Vyšetřovatel
user_rank_8=Očko
user_rank_9=Vševidicí očko
user_rank_10=Detektiv
user_rank_11=Vedoucí detektiv
sync_request_dialog_text=Zadej číslo průkazu:
sync_request_button=Synchronizovat uživatele
......@@ -168,5 +168,19 @@ user_consecutivelyallgames2stars_description=Für alle Spiele nacheinander auf d
user_consecutivelyallgames3stars=Als DetektivIn ein Raubtier
user_consecutivelyallgames3stars_description=Für alle Spiele nacheinander auf der schwierigen Stufe mit drei Pokalen
# <!-- Ranky -->
user_rank_promotion=Povýšení
user_rank_1=Zástupce zelenáče
user_rank_2=Zelenáč
user_rank_3=Čmuchal
user_rank_4=Pátral
user_rank_5=Vrchní pátral
user_rank_6=Inspektor
user_rank_7=Vyšetřovatel
user_rank_8=Očko
user_rank_9=Vševidicí očko
user_rank_10=Detektiv
user_rank_11=Vedoucí detektiv
sync_request_dialog_text=Trage deine Ausweisnummer ein:
sync_request_button=Account synchronisieren
......@@ -170,5 +170,19 @@ user_consecutivelyallgames2stars_description=Za všetky hry po sebe na strednú
user_consecutivelyallgames3stars=Detektívna šelma
user_consecutivelyallgames3stars_description=Za všetky hry po sebe na ťažkú obtiažnosť a tri poháre.
# <!-- Ranky -->
user_rank_promotion=Povýšení
user_rank_1=Zástupce zelenáče
user_rank_2=Zelenáč
user_rank_3=Čmuchal
user_rank_4=Pátral
user_rank_5=Vrchní pátral
user_rank_6=Inspektor
user_rank_7=Vyšetřovatel
user_rank_8=Očko
user_rank_9=Vševidicí očko
user_rank_10=Detektiv
user_rank_11=Vedoucí detektiv
sync_request_dialog_text=Zadaj číslo preukazu:
sync_request_button=Synchronizovať užívateľa
\ No newline at end of file
sync_request_button=Synchronizovať užívateľa
......@@ -840,6 +840,17 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
victoryDialog.show(DIALOG_WIDTH, DIALOG_HEIGHT);
animateAndPlayVictoryDialogSounds(gameResult, cupsImages);
// //TODO REMOVE
// final float SHOW_DELAY = 1.5f;
//
// TablexiaComponentDialogFactory.getDialogStage().addAction(new SequenceAction(Actions.delay(SHOW_DELAY), Actions.run(new Runnable() {
// @Override
// public void run() {
// if(victoryDialog != null && victoryDialog.isVisible() && victoryDialog.getColor().a > 0)
// onRankup(UserRankManager.UserRank.RANK_II, UserRankManager.UserRank.RANK_III);
// }
// })));
}
private void animateAndPlayVictoryDialogSounds(GameResult gameResult, Image[] cups) {
......@@ -1007,37 +1018,45 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
UserRankManager.getRank(getSelectedUser()); //TODO - refreshing user
}
public void showRankUp() {
public void onRankup(UserRankManager.UserRank previousRank, UserRankManager.UserRank newRank) {
//TODO - constants
final float DIMMER = 0.7f;
final float SHINE_ALPHA = 0.45f;
//Dimmer
final float DIMMER_ALPHA = 0.7f;
final Color DIMMER_COLOR = new Color(0, 0, 0, DIMMER_ALPHA);
//Shine
final int BACKGROUND_SHINE_COUNT = 6;
final float SHINE_ROTATION = 67.8f;
final float SHINE_ALPHA = 0.45f;
final Color[] SHINE_COLORS = new Color[] {
new Color(1, 1, 190/255f, SHINE_ALPHA),
new Color(1, 190/255f, 1, SHINE_ALPHA),
new Color(190/255f, 1, 1, SHINE_ALPHA)
};
final float ROTATION_SPEED = 9;
final float ROTATION_SPEED_DIFF = 2;
final int BACKGROUND_SHINE_COUNT = 3;
//Fade time
final float FADE_TIME = 0.5f;
//Dialog stage
Stage dialogStage = TablexiaComponentDialogFactory.getDialogStage();
final Group group = new Group();
//TODO - remove victory dialog get stage thing...
group.setSize(dialogStage.getWidth(), dialogStage.getHeight());
UserRankManager.UserRank rank = UserRankManager.getRank(getSelectedUser());
Image dimmer = new Image(ApplicationAtlasManager.getInstance().getColorTexture(Color.BLACK));
//Adding dimmer
Image dimmer = new Image(ApplicationAtlasManager.getInstance().getColorTexture(DIMMER_COLOR));
dimmer.setSize(dialogStage.getWidth(), getStage().getHeight());
dimmer.setPosition(0, 0);
dimmer.setColor(1, 1, 1, DIMMER);
group.addActor(dimmer);
//Adding shines
Image[] images = new Image[BACKGROUND_SHINE_COUNT];
for(int i = 0; i < BACKGROUND_SHINE_COUNT; i++) {
images[i] = new Image(ApplicationAtlasManager.getInstance().getTextureRegion(ApplicationAtlasManager.RANK_UP_BACKGROUND));
images[i].setSize(dialogStage.getWidth(), dialogStage.getHeight());
images[i].setOrigin(Align.center);
images[i].setColor(1, 1, 200/255f, SHINE_ALPHA);
images[i].setColor(SHINE_COLORS[i % SHINE_COLORS.length]);
images[i].setRotation(i *SHINE_ROTATION);
......@@ -1049,21 +1068,30 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
group.addActor(images[i]);
}
Image badge = new Image(ApplicationAtlasManager.getInstance().getTextureRegion(rank.getBadgeImage()));
//Adding badge
Image badge = new Image(ApplicationAtlasManager.getInstance().getTextureRegion(newRank.getBadgeImage()));
badge.setPosition(dialogStage.getWidth()/2 - badge.getWidth() / 2, dialogStage.getHeight()/2 - badge.getHeight() / 2);
group.addActor(badge);
TablexiaLabel textup = new TablexiaLabel("Povýšen", new TablexiaLabel.TablexiaLabelStyle(ApplicationFontManager.FontType_NEW.BOLD_55, Color.WHITE));
textup.setPosition(0, dialogStage.getHeight()/2 + 100);
textup.setSize(dialogStage.getWidth(), textup.getHeight());
textup.setAlignment(Align.center);
group.addActor(textup);
TablexiaLabel textdown = new TablexiaLabel("TODO - Nazev Hodnosti", new TablexiaLabel.TablexiaLabelStyle(ApplicationFontManager.FontType_NEW.BOLD_20, Color.WHITE));
textdown.setPosition(0, dialogStage.getHeight()/2 - 120);
textdown.setSize(dialogStage.getWidth(), textdown.getHeight());
textdown.setAlignment(Align.center);
group.addActor(textdown);
//Promotion lable
TablexiaLabel promotionLabel = new TablexiaLabel(
ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USER_RANK_PROMOTION),
new TablexiaLabel.TablexiaLabelStyle(ApplicationFontManager.FontType_NEW.BOLD_55, Color.WHITE)
);
promotionLabel.setPosition(0, dialogStage.getHeight()/2 + 100);
promotionLabel.setSize(dialogStage.getWidth(), promotionLabel.getHeight());
promotionLabel.setAlignment(Align.center);
group.addActor(promotionLabel);
//Rank name label
TablexiaLabel rankNameLabel = new TablexiaLabel(
ApplicationTextManager.getInstance().getText(newRank.getNameKey()),
new TablexiaLabel.TablexiaLabelStyle(ApplicationFontManager.FontType_NEW.BOLD_20, Color.WHITE)
);
rankNameLabel.setPosition(0, dialogStage.getHeight()/2 - 120);
rankNameLabel.setSize(dialogStage.getWidth(), rankNameLabel.getHeight());
rankNameLabel.setAlignment(Align.center);
group.addActor(rankNameLabel);
group.addListener(new ClickListener() {
@Override
......@@ -1080,14 +1108,14 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
}
@Handler
public void onUserRankUpEvent(UserRankManager.UserRankUpEvent userRankUpEvent) {
public void onUserRankUpEvent(final UserRankManager.UserRankUpEvent userRankUpEvent) {
final float SHOW_DELAY = 1.5f;
TablexiaComponentDialogFactory.getDialogStage().addAction(new SequenceAction(Actions.delay(SHOW_DELAY), Actions.run(new Runnable() {
@Override
public void run() {
if(victoryDialog != null && victoryDialog.isVisible() && victoryDialog.getColor().a > 0)
showRankUp();
onRankup(userRankUpEvent.getPreviousRank(), userRankUpEvent.getNewRank());
}
})));
}
......
......@@ -414,10 +414,6 @@ public class PursuitGame extends AbstractTablexiaGame<int[][]> {
vehicle.remove();
finishFlag.clear();
finishFlag.remove();
getSelectedUser().setRankRefreshNeeded(true);
UserRankManager.getRank(getSelectedUser()); //TODO - refresh user
showRankUp();
}
}));
vehicle.setDebug(TablexiaSettings.getInstance().isShowBoundingBoxes());
......
package cz.nic.tablexia.game.ranksystem;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.model.game.GameDAO;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.util.Log;
/**
* Created by bcx on 4/15/16.
*/
public class UserRankManager {
public enum UserRank {
RANK_I ( 0, ApplicationAtlasManager.BADGE_0, ApplicationAtlasManager.BADGE_0_ICON, new int[]{ 0, 0, 0, 0, 0, 0}),
RANK_II ( 1, ApplicationAtlasManager.BADGE_1, ApplicationAtlasManager.BADGE_1_ICON, new int[]{ 3, 3, 3, 3, 3, 3}),
RANK_III ( 2, ApplicationAtlasManager.BADGE_2, ApplicationAtlasManager.BADGE_2_ICON, new int[]{ 6, 6, 6, 6, 6, 6}),
RANK_IV ( 3, ApplicationAtlasManager.BADGE_3, ApplicationAtlasManager.BADGE_3_ICON, new int[]{ 12, 12, 12, 12, 12, 12}),
RANK_V ( 4, ApplicationAtlasManager.BADGE_4, ApplicationAtlasManager.BADGE_4_ICON, new int[]{ 21, 21, 21, 21, 21, 21}),
RANK_VI ( 5, ApplicationAtlasManager.BADGE_5, ApplicationAtlasManager.BADGE_5_ICON, new int[]{ 36, 36, 36, 36, 36, 36}),
RANK_VII ( 6, ApplicationAtlasManager.BADGE_6, ApplicationAtlasManager.BADGE_6_ICON, new int[]{ 48, 48, 48, 48, 48, 48}),
RANK_VIII ( 7, ApplicationAtlasManager.BADGE_7, ApplicationAtlasManager.BADGE_7_ICON, new int[]{ 60, 60, 60, 60, 60, 60}),
RANK_IX ( 8, ApplicationAtlasManager.BADGE_8, ApplicationAtlasManager.BADGE_8_ICON, new int[]{ 74, 74, 74, 74, 74, 74}),
RANK_X ( 9, ApplicationAtlasManager.BADGE_9, ApplicationAtlasManager.BADGE_9_ICON, new int[]{ 86, 86, 86, 86, 86, 86}),
RANK_XI (10, ApplicationAtlasManager.BADGE_10, ApplicationAtlasManager.BADGE_10_ICON, new int[]{ 98, 98, 98, 98, 98, 98});
RANK_I ( 0, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_I, ApplicationAtlasManager.BADGE_0, ApplicationAtlasManager.BADGE_0_ICON, new int[]{ 0, 0, 0, 0, 0, 0}),
RANK_II ( 1, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_II, ApplicationAtlasManager.BADGE_1, ApplicationAtlasManager.BADGE_1_ICON, new int[]{ 3, 3, 3, 3, 3, 3}),
RANK_III ( 2, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_III, ApplicationAtlasManager.BADGE_2, ApplicationAtlasManager.BADGE_2_ICON, new int[]{ 6, 6, 6, 6, 6, 6}),
RANK_IV ( 3, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_IV, ApplicationAtlasManager.BADGE_3, ApplicationAtlasManager.BADGE_3_ICON, new int[]{ 12, 12, 12, 12, 12, 12}),
RANK_V ( 4, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_V, ApplicationAtlasManager.BADGE_4, ApplicationAtlasManager.BADGE_4_ICON, new int[]{ 21, 21, 21, 21, 21, 21}),
RANK_VI ( 5, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_VI, ApplicationAtlasManager.BADGE_5, ApplicationAtlasManager.BADGE_5_ICON, new int[]{ 36, 36, 36, 36, 36, 36}),
RANK_VII ( 6, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_VII, ApplicationAtlasManager.BADGE_6, ApplicationAtlasManager.BADGE_6_ICON, new int[]{ 48, 48, 48, 48, 48, 48}),
RANK_VIII ( 7, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_VIII, ApplicationAtlasManager.BADGE_7, ApplicationAtlasManager.BADGE_7_ICON, new int[]{ 60, 60, 60, 60, 60, 60}),
RANK_IX ( 8, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_IX, ApplicationAtlasManager.BADGE_8, ApplicationAtlasManager.BADGE_8_ICON, new int[]{ 74, 74, 74, 74, 74, 74}),
RANK_X ( 9, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_X, ApplicationAtlasManager.BADGE_9, ApplicationAtlasManager.BADGE_9_ICON, new int[]{ 86, 86, 86, 86, 86, 86}),
RANK_XI (10, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_XI, ApplicationAtlasManager.BADGE_10, ApplicationAtlasManager.BADGE_10_ICON, new int[]{ 98, 98, 98, 98, 98, 98});
private int id;
private String nameKey;
private String badgeImage, badgeIcon;
private int[] experiencePointsNeeded;
UserRank(int id, String badgeImage, String badgeIcon, int[] experiencePointsNeeded) {
UserRank(int id, String nameKey, String badgeImage, String badgeIcon, int[] experiencePointsNeeded) {
this.id = id;
this.nameKey = nameKey;
this.badgeImage = badgeImage;
this.badgeIcon = badgeIcon;
this.experiencePointsNeeded = experiencePointsNeeded;
......@@ -46,6 +44,10 @@ public class UserRankManager {
return id;
}
public String getNameKey() {
return nameKey;
}
public static UserRank getRank(int id) {
for(UserRank rank : values()) {
if(rank.getId() == id)
......
......@@ -93,6 +93,19 @@ public class ApplicationTextManager extends TablexiaDataManager<I18NBundle> impl
public static final String SYNC_REQUEST_DIALOG_TEXT = "sync_request_dialog_text";
public static final String SYNC_REQUEST_BUTTON = "sync_request_button";
public static final String USER_RANK_PROMOTION = "user_rank_promotion";
public static final String USER_RANK_I = "user_rank_1";
public static final String USER_RANK_II = "user_rank_2";
public static final String USER_RANK_III = "user_rank_3";
public static final String USER_RANK_IV = "user_rank_4";
public static final String USER_RANK_V = "user_rank_5";
public static final String USER_RANK_VI = "user_rank_6";
public static final String USER_RANK_VII = "user_rank_7";
public static final String USER_RANK_VIII = "user_rank_8";
public static final String USER_RANK_IX = "user_rank_9";
public static final String USER_RANK_X = "user_rank_10";
public static final String USER_RANK_XI = "user_rank_11";
}
private static final String APPLICATION_TEXT_RESOURCE_FILE = "text/application/application";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment