Skip to content
Snippets Groups Projects
Commit a25378a7 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

#5 Info item position for different backgrounds

parent 06ebf09c
No related branches found
No related tags found
No related merge requests found
......@@ -98,7 +98,7 @@ public class GameScreen extends AbstractRobberyScreen {
}
}
public static void init(Group infoItemLayer, Group colorInfoLayer, AbstractRobberyScreen abstractRobberyScreen) {
public static void init(Group infoItemLayer, Group colorInfoLayer, SceneBackground sceneBackground, AbstractRobberyScreen abstractRobberyScreen) {
for (InfoItem container : InfoItem.values()) {
container.init(abstractRobberyScreen);
container.infoItemGroup.setVisible(false);
......@@ -108,12 +108,12 @@ public class GameScreen extends AbstractRobberyScreen {
colorInfoLayer.addActor(container.infoBanner);
}
}
calculateDimensions(infoItemLayer.getStage().getWidth(), infoItemLayer.getStage().getHeight());
calculateDimensions(infoItemLayer.getStage().getWidth(), infoItemLayer.getStage().getHeight(), sceneBackground);
}
public static void calculateDimensions(float width, float height) {
float infoItemPositionX = width * INFOITEM_POSITION_X_RATIO;
float infoItemPositionY = height * INFOITEM_POSITION_Y_RATIO;
public static void calculateDimensions(float width, float height, SceneBackground sceneBackground) {
float infoItemPositionX = width * sceneBackground.getInfoitemPositionXRatio();
float infoItemPositionY = height * sceneBackground.getInfoitemPositionYRatio();
for (InfoItem container : InfoItem.values()) {
container.infoItemGroup.setSize(container.infoItem.getWidth(), container.infoItem.getHeight() + container.infoItemTitle.getHeight());
......@@ -132,19 +132,23 @@ public class GameScreen extends AbstractRobberyScreen {
private enum SceneBackground {
NEWSSTAND (GameDifficulty.EASY, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND_BOTTOM),
JEWELLERY (GameDifficulty.MEDIUM, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY_BOTTOM),
BANK (GameDifficulty.HARD, RobberyAssets.SCREEN_BACKGROUND_BANK, RobberyAssets.SCREEN_BACKGROUND_BANK_BOTTOM);
NEWSSTAND (GameDifficulty.EASY, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND_BOTTOM, 11f/36, 5f/14),
JEWELLERY (GameDifficulty.MEDIUM, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY_BOTTOM, 59f/160, 9f/28),
BANK (GameDifficulty.HARD, RobberyAssets.SCREEN_BACKGROUND_BANK, RobberyAssets.SCREEN_BACKGROUND_BANK_BOTTOM, 23f/72, 11f/28);
private final GameDifficulty gameDifficulty;
private final String sceneBackground;
private final String sceneBackgroundBottom;
private final float infoitemPositionXRatio;
private final float infoitemPositionYRatio;
SceneBackground(GameDifficulty gameDifficulty, String sceneBackground, String sceneBackgroundBottom) {
SceneBackground(GameDifficulty gameDifficulty, String sceneBackground, String sceneBackgroundBottom, float infoitemPositionXRatio, float infoitemPositionYRatio) {
this.gameDifficulty = gameDifficulty;
this.sceneBackground = sceneBackground;
this.sceneBackgroundBottom = sceneBackgroundBottom;
}
this.infoitemPositionXRatio = infoitemPositionXRatio;
this.infoitemPositionYRatio = infoitemPositionYRatio;
}
public String getSceneBackground() {
return sceneBackground;
......@@ -154,6 +158,14 @@ public class GameScreen extends AbstractRobberyScreen {
return sceneBackgroundBottom;
}
public float getInfoitemPositionXRatio() {
return infoitemPositionXRatio;
}
public float getInfoitemPositionYRatio() {
return infoitemPositionYRatio;
}
public static SceneBackground getSceneBackgroundForDifficulty(GameDifficulty gameDifficulty) {
for (SceneBackground background : SceneBackground.values()) {
if (background.gameDifficulty == gameDifficulty) {
......@@ -168,9 +180,7 @@ public class GameScreen extends AbstractRobberyScreen {
private static final Color COLOR_KO = Color.valueOf("c1272dff");
private static final float COLORBANNER_X_POSITION_RATIO = 1f/2;
private static final float COLORBANNER_WIDTH_RATIO = 1f/3;
private static final float INFOITEM_POSITION_Y_RATIO = 5f/14;
private static final float INFOITEM_POSITION_X_RATIO = 11f/36;
private static final Interpolation INFOITEM_HIDE_INTERPOLATION = Interpolation.pow4In;
private static final Interpolation INFOITEM_SHOW_ALPHA_INTERPOLATION = Interpolation.pow4Out;
private static final Interpolation INFOITEM_SHOW_SCALE_INTERPOLATION = Interpolation.swingOut;
......@@ -244,7 +254,7 @@ public class GameScreen extends AbstractRobberyScreen {
getStage().addActor(sceneBackground);
getStage().addActor(infoItemLayer);
InfoItem.init(infoItemLayer, colorInfoLayer, this);
InfoItem.init(infoItemLayer, colorInfoLayer, sceneBackgroundDefinition, this);
prepareCreaturePositions(getStage().getViewport().getWorldWidth(), getStage().getViewport().getWorldHeight());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment