Commit b5b8934a authored by Matyáš Latner's avatar Matyáš Latner

Merge branch 'V3.4' into feature-copyright2

parents 2d417b36 e61a050c
[submodule "core/external"]
[submodule "core/external/tablexia-shared"]
path = core/external/tablexia-shared
url = git@gitlab.labs.nic.cz:labs/tablexia-model.git
[submodule "core/external/copyright-test"]
......
......@@ -16,8 +16,8 @@
#
game_nocnisledovani_btncontinue_text=Hotovo
victory_text_window_mistakes=Chybně označená okna: [BLACK]{0}[]
victory_text_time_mistakes=Chybně nastavený čas: [BLACK]{0}[]
victory_text_rounds=Počet bodů: [BLACK]{0}[]
game_nocnisledovani_loadingtext=Dávej pozor, která okna se po setmění rozsvítí a v kolik hodin. Po rozednění nastav na hodinách čas a označ okna, která byla rozsvícená.
game_nocnisledovani_victory_text_0=To vypadá, že tady někdo usnul na\u00A0hlídce.
game_nocnisledovani_victory_text_1=U\u00A0soudu by tyhle důkazy neuspěly. To ale neznamená, že se nemůže zadařit příště!
game_nocnisledovani_victory_text_2=Tohle nebylo vůbec špatné! Stačilo málo a důkazy by byly neprůstřelné.
......
......@@ -16,8 +16,8 @@
#
game_nocnisledovani_btncontinue_text=Fertig
victory_text_window_mistakes=Falsch markierte Fenster: [BLACK]{0}[]
victory_text_time_mistakes=Falsch eingestellte Zeit: [BLACK]{0}[]
victory_text_rounds=Punktezahl: [BLACK]{0}[]
game_nocnisledovani_loadingtext=Pass auf, welche Fenster nach Einbruch der Dunkelheit leuchten und um wieviel Uhr. Stelle nach Tageseinbruch in der Uhr die Zeit ein und markiere die Fenster, die geleuchtet haben.
game_nocnisledovani_victory_text_0=Es sieht so aus, als wäre hier jemand bei der Wache eingeschlafen.
game_nocnisledovani_victory_text_1=Vor Gericht hätten diese Beweise keinen Erfolg. Das heißt aber nicht, dass es nächstes Mal nicht gelingen kann!
game_nocnisledovani_victory_text_2=Das war gar nicht schlecht! Es fehlt nicht viel und die Beweise wären bombensicher.
......
......@@ -16,8 +16,8 @@
#
game_nocnisledovani_btncontinue_text=Hotovo
victory_text_window_mistakes=Chybne označené okná: [BLACK]{0}[]
victory_text_time_mistakes=Chybne nastavený čas: [BLACK]{0}[]
victory_text_rounds=Počet bodov: [BLACK]{0}[]
game_nocnisledovani_loadingtext=Dávaj pozor, ktoré okná sa po\u00A0zotmení rozsvietia a o\u00A0ktorej. Po\u00A0svitaní nastav na\u00A0hodinách čas a označ okná, ktoré boli rozsvietené.
game_nocnisledovani_victory_text_0=Vyzerá to tak, že tu niekto zaspal na\u00A0hliadke.
game_nocnisledovani_victory_text_1=Na súde by tieto dôkazy neuspeli. To ale neznamená, že sa to nemôže podariť!
game_nocnisledovani_victory_text_2=To vôbec nebolo zlé! Stačilo málo a dôkazy by boli nepriestrelné.
......
/Model/nbproject/private/
\ No newline at end of file
Subproject commit 473867f6fa7f1721cb93f706a050f0b136647ec5
Subproject commit 68850450f6feeaaa7699750a5b2515549a60eaa1
......@@ -60,11 +60,6 @@ public class TablexiaSettings {
public static final String LOCALE_KEY = "locale";
private static final String SELECTED_USER = "selected_user";
public static final int EXPERIENCE_POINTS_TUTORIAL = 0;
public static final int EXPERIENCE_POINTS_EASY = 1;
public static final int EXPERIENCE_POINTS_MEDIUM = 2;
public static final int EXPERIENCE_POINTS_HARD = 3;
//Interval <start month; end month>
private static final int WINTER_MODE_START_MONTH = 10;
private static final int WINTER_MODE_END_MONTH = 2;
......@@ -429,26 +424,26 @@ public class TablexiaSettings {
}
public enum LocaleDefinition {
SYSTEM (null, "system", 0, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SYSTEM, true),
cs_CZ (new Locale("cs", "CZ"), "cs_CZ", 1, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_CZECH, true),
sk_SK (new Locale("sk", "SK"), "sk_SK", 2, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SLOVAK, true),
de_DE (new Locale("de", "DE"), "de_DE", 3, ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_GERMAN, true);
SYSTEM (null, null, "system", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SYSTEM, true),
cs_CZ (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.cs_CZ, new Locale("cs", "CZ"), "cs_CZ", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_CZECH, true),
sk_SK (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.sk_SK, new Locale("sk", "SK"), "sk_SK", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SLOVAK, true),
de_DE (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.de_DE, new Locale("de", "DE"), "de_DE", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_GERMAN, true);
public final static LocaleDefinition DEFAULT_LOCALE = LocaleDefinition.cs_CZ;
private final static LocaleDefinition FALLBACK_VARIANT = LocaleDefinition.SYSTEM;
private final cz.nic.tablexia.shared.model.definitions.LocaleDefinition modelLocaleDefinition;
private final Locale locale;
private final String localeKey;
private final int localeNumber;
private final String descriptionKey;
private boolean enabled;
private final boolean enabled;
private static List<LocaleDefinition> enabledLocaleDefinitions;
LocaleDefinition(Locale locale, String localeKey, int localeNumber, String descriptionKey, boolean enabled) {
LocaleDefinition(cz.nic.tablexia.shared.model.definitions.LocaleDefinition modelLocaleDefinition, Locale locale, String localeKey, String descriptionKey, boolean enabled) {
this.modelLocaleDefinition = modelLocaleDefinition;
this.locale = locale;
this.localeKey = localeKey;
this.localeNumber = localeNumber;
this.descriptionKey = descriptionKey;
this.enabled = enabled;
}
......@@ -458,7 +453,7 @@ public class TablexiaSettings {
}
public int getLocaleNumber() {
return localeNumber;
return getLocaleDefinitionForLocale(getLocale()).modelLocaleDefinition.number();
}
public String getDescriptionKey() {
......
......@@ -79,6 +79,8 @@ import cz.nic.tablexia.screen.halloffame.trophy.TrophyHelper;
import cz.nic.tablexia.screen.profile.ProfileScreen;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.GameScore;
import cz.nic.tablexia.shared.model.definitions.DifficultyDefinition;
import cz.nic.tablexia.shared.model.definitions.GameResultDefinition;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.MusicUtil;
import cz.nic.tablexia.util.actions.MoveAlongAction;
......@@ -127,30 +129,43 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
public enum GameResult {
NO_STAR(0, null),
ONE_STAR(1, RATINGSTAR1_SOUND),
TWO_STAR(2, RATINGSTAR2_SOUND),
THREE_STAR(3, RATINGSTAR3_SOUND);
NO_STAR (GameResultDefinition.NO_STAR, null),
ONE_STAR (GameResultDefinition.ONE_STAR, RATINGSTAR1_SOUND),
TWO_STAR (GameResultDefinition.TWO_STAR, RATINGSTAR2_SOUND),
THREE_STAR (GameResultDefinition.THREE_STAR, RATINGSTAR3_SOUND);
private int starCount;
private GameResultDefinition gameResultDefinition;
private String startSoundName;
GameResult(int starCount, String startSoundName) {
this.starCount = starCount;
GameResult(GameResultDefinition gameResultDefinition, String startSoundName) {
this.gameResultDefinition = gameResultDefinition;
this.startSoundName = startSoundName;
}
public int getStarCount() {
return starCount;
return gameResultDefinition.number();
}
public String getStartSoundName() {
return startSoundName;
}
public GameResultDefinition getGameResultDefinition() {
return gameResultDefinition;
}
public static GameResult getGameResultForStartCount(int starCount) {
for (GameResult gameResult : GameResult.values()) {
if (gameResult.starCount == starCount) {
if (gameResult.getStarCount() == starCount) {
return gameResult;
}
}
return null;
}
public static GameResult getGameResultForGameResultDefinition(GameResultDefinition gameCupsResult) {
for(GameResult gameResult : values()) {
if(gameResult.gameResultDefinition == gameCupsResult) {
return gameResult;
}
}
......@@ -514,7 +529,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
@Override
public void clicked(InputEvent event, float x, float y) {
if(getGamePhase() == GamePhase.STARTED) {
forceGameEnd(GameResult.THREE_STAR);
forceGameEnd(GameResultDefinition.THREE_STAR);
debugEndGameButton.setDisabled();
}
}
......@@ -1369,15 +1384,15 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
ApplicationBus.getInstance().publishAsync(new StartIncrementalSynchronizationEvent(getSelectedUser().getId()));
}
private void forceGameEnd(GameResult gameResult) {
List<GameScore> gameScores = GameDefinition.getGameDefinitionForClass(getClass()).getGameResultResolver().getGameScoreList(getGameDifficulty(), gameResult);
private void forceGameEnd(GameResultDefinition gameResult) {
List<GameScore> gameScores = GameDefinition.getGameDefinitionForClass(getClass()).getGameResultResolver().getExampleScoreForGameResult(getGameDifficulty().getDifficultyDefinition(), gameResult);
setGameScores(gameScores);
waitForActualGameScore();
onForceGameEnd(gameResult);
}
protected void onForceGameEnd(GameResult gameResult) {
protected void onForceGameEnd(GameResultDefinition gameResult) {
endGame();
showGameResultDialog();
}
......
......@@ -23,6 +23,7 @@ import java.util.List;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.definitions.DifficultyDefinition;
/**
* Game difficulty types
......@@ -31,29 +32,31 @@ import cz.nic.tablexia.shared.model.Game;
*/
public enum GameDifficulty {
TUTORIAL(0, TablexiaSettings.EXPERIENCE_POINTS_TUTORIAL, "gamedifficulty_tutorial", false, false),
EASY (1, TablexiaSettings.EXPERIENCE_POINTS_EASY, "gamedifficulty_easy", true, true),
MEDIUM (2, TablexiaSettings.EXPERIENCE_POINTS_MEDIUM, "gamedifficulty_medium", true, true),
HARD (3, TablexiaSettings.EXPERIENCE_POINTS_HARD, "gamedifficulty_hard", true, true);
TUTORIAL(DifficultyDefinition.TUTORIAL, "gamedifficulty_tutorial", false, false),
EASY (DifficultyDefinition.EASY, "gamedifficulty_easy", true, true),
MEDIUM (DifficultyDefinition.MEDIUM, "gamedifficulty_medium", true, true),
HARD (DifficultyDefinition.HARD, "gamedifficulty_hard", true, true);
public static final GameDifficulty DEFAULT_DIFFICULTY = EASY;
private int difficultyNumber;
private int experiencePointsMultiplier;
private String descriptionResourceKey;
private boolean visible;
private boolean hasScore;
private final DifficultyDefinition difficultyDefinition;
private final String descriptionResourceKey;
private final boolean visible;
private final boolean hasScore;
GameDifficulty(int difficultyNumber, int experiencePointsMultiplier, String descriptionResourceKey, boolean visible, boolean hasScore) {
this.difficultyNumber = difficultyNumber;
this.experiencePointsMultiplier = experiencePointsMultiplier;
GameDifficulty(DifficultyDefinition difficultyDefinition, String descriptionResourceKey, boolean visible, boolean hasScore) {
this.difficultyDefinition = difficultyDefinition;
this.descriptionResourceKey = descriptionResourceKey;
this.visible = visible;
this.hasScore = hasScore;
}
public DifficultyDefinition getDifficultyDefinition() {
return difficultyDefinition;
}
public int getDifficultyNumber() {
return difficultyNumber;
return difficultyDefinition.number();
}
public String getTextDescription() {
......@@ -85,7 +88,7 @@ public enum GameDifficulty {
public static GameDifficulty getGameDifficultyForDifficultyNumber(int difficultyNumber) {
for (GameDifficulty gameDifficulty: GameDifficulty.values()) {
if (gameDifficulty.difficultyNumber == difficultyNumber) {
if (gameDifficulty.difficultyDefinition.number() == difficultyNumber) {
return gameDifficulty;
}
}
......@@ -97,7 +100,7 @@ public enum GameDifficulty {
}
public int getExperiencePointsMultiplier() {
return experiencePointsMultiplier;
return difficultyDefinition.getExperiencePointsMultiplier();
}
public boolean hasScore() {
......
......@@ -40,7 +40,6 @@ import java.util.TimerTask;
import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.crime_scene.actors.PlaySoundScreen;
import cz.nic.tablexia.game.games.crime_scene.assets.CrimeSceneAssets;
......@@ -50,7 +49,7 @@ import cz.nic.tablexia.game.games.crime_scene.gameobject.GameObjectType;
import cz.nic.tablexia.game.games.crime_scene.model.*;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationInternalTextureManager;
import cz.nic.tablexia.shared.model.GameScore;
import cz.nic.tablexia.shared.model.resolvers.CrimeSceneScoreResolver;
import cz.nic.tablexia.util.ScaleUtil;
import cz.nic.tablexia.util.ui.AnimatedImage;
import cz.nic.tablexia.util.ui.actionwidget.Action;
......@@ -82,8 +81,9 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> {
private static final int GAME_MAP_PADDING = 25;
private static final int GAME_MAP_SIZE = 625;
private static final int ACTION_CARD_EXTRA_LARGE = 2 * ACTION_CARD_DRAG_SIZE;
private static final String SCORE_KEY_COUNT = "score_count";
private static final String RESULT_SCORE_COUNT = "result_score_count";
private static final String SCORE_KEY_COUNT = CrimeSceneScoreResolver.SCORE_KEY_COUNT;
private static final String RESULT_SCORE_COUNT = CrimeSceneScoreResolver.RESULT_SCORE_COUNT;
private static final float ANIMATION_DURATION = 0.3f;
private static final float FADE_DURATION = 1f;
......@@ -123,39 +123,6 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> {
private int level = 1;
private int wrongRounds = 0;
public static class GameResultResolver extends GameDefinition.GameResultResolver {
private static final String FORMATTED_TEXT_FOR_STATISTICS_FORMAT = "%d / %d";
@Override
public AbstractTablexiaGame.GameResult getGameCupsResult(Game game) {
return ResultStars.getStarCountForDifficultyAndErrors(GameDifficulty.getGameDifficultyForDifficultyNumber(game.getGameDifficulty()),
Integer.parseInt(game.getGameScore(SCORE_KEY_COUNT, String.valueOf(correctSounds))));
}
@Override
public float getGameScoreResult(Game game) {
return Float.parseFloat(game.getGameScore(SCORE_KEY_COUNT, String.valueOf(correctSounds)));
}
@Override
public float getStatisticsScore(Game game) {
//Score to sort graph values in statistics is calculated as "actualScore / maxScore". So 2 cups on hard difficulty wont show up higher than 3 cups on medium difficulty.
return getGameScoreResult(game) / (float)(getMaxScoreForDifficulty(GameDifficulty.getGameDifficultyForDifficultyNumber(game.getGameDifficulty())));
}
@Override
public String getFormattedScoreForStatistics(Game game) {
return String.format(FORMATTED_TEXT_FOR_STATISTICS_FORMAT, Math.round(getGameScoreResult(game)), getMaxScoreForDifficulty(GameDifficulty.getGameDifficultyForDifficultyNumber(game.getGameDifficulty())));
}
@Override
public List<GameScore> getGameScoreList(GameDifficulty difficulty, GameResult result) {
ArrayList gameScoreList = new ArrayList<GameScore>(1);
gameScoreList.add(new GameScore(SCORE_KEY_COUNT, String.valueOf(ResultStars.getScoreForGameResultAndDifficulty(result, difficulty))));
return gameScoreList;
}
}
@Override
protected void gameLoaded(java.util.Map gameState) {
setUpActionsStripWidget();
......
......@@ -24,6 +24,7 @@ import java.util.Random;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.in_the_darkness.action.InTheDarknessActionType;
import cz.nic.tablexia.game.games.in_the_darkness.map.IMapProvider;
import cz.nic.tablexia.game.games.in_the_darkness.map.InTheDarknessMap;
import cz.nic.tablexia.game.games.in_the_darkness.map.MapGenerator;
import cz.nic.tablexia.game.games.in_the_darkness.map.MapTutorial;
import cz.nic.tablexia.util.Log;
......@@ -36,23 +37,25 @@ import cz.nic.tablexia.util.Log;
*/
public enum InTheDarknessDifficulty {
TUTORIAL(GameDifficulty.TUTORIAL, false, MapTutorial.class, 1, Arrays.asList(new InTheDarknessActionType[]{})),
EASY (GameDifficulty.EASY, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{})),
MEDIUM (GameDifficulty.MEDIUM, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{InTheDarknessActionType.KEY})),
HARD (GameDifficulty.HARD, true, MapGenerator.class, 2, Arrays.asList(new InTheDarknessActionType[]{InTheDarknessActionType.KEY}));
TUTORIAL(GameDifficulty.TUTORIAL, false, MapTutorial.class, 1, Arrays.asList(new InTheDarknessActionType[]{}), InTheDarknessMap.SMALL_MAP),
EASY (GameDifficulty.EASY, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{}), InTheDarknessMap.SMALL_MAP),
MEDIUM (GameDifficulty.MEDIUM, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{}), InTheDarknessMap.LARGE_MAP),
HARD (GameDifficulty.HARD, true, MapGenerator.class, 1, Arrays.asList(new InTheDarknessActionType[]{InTheDarknessActionType.KEY}), InTheDarknessMap.LARGE_MAP);
private GameDifficulty gameDifficulty;
private int floorCount;
private InTheDarknessMap map;
private List<InTheDarknessActionType> difficultyInTheDarknessActionTypes;
private Class<? extends IMapProvider> mapProviderClass;
private boolean hasResults;
InTheDarknessDifficulty(GameDifficulty gameDifficulty, boolean hasResults, Class<? extends IMapProvider> mapProviderClass, int floorCount, List<InTheDarknessActionType> difficultyInTheDarknessActionTypes) {
InTheDarknessDifficulty(GameDifficulty gameDifficulty, boolean hasResults, Class<? extends IMapProvider> mapProviderClass, int floorCount, List<InTheDarknessActionType> difficultyInTheDarknessActionTypes, InTheDarknessMap map) {
this.gameDifficulty = gameDifficulty;
this.hasResults = hasResults;
this.mapProviderClass = mapProviderClass;
this.floorCount = floorCount;
this.difficultyInTheDarknessActionTypes = difficultyInTheDarknessActionTypes;
this.map = map;
}
public boolean hasResults() {
......@@ -63,6 +66,10 @@ public enum InTheDarknessDifficulty {
return floorCount;
}
public InTheDarknessMap getMap() {
return map;
}
public boolean hasDifficultyActionType(InTheDarknessActionType inTheDarknessActionType) {
return difficultyInTheDarknessActionTypes.contains(inTheDarknessActionType);
}
......
......@@ -26,7 +26,8 @@ public final class InTheDarknessAssets {
public static final String BACKGROUND_PATH = GFX_PATH + "background/";
public static final String BACKGROUND = BACKGROUND_PATH + "background";
public static final String BACKGROUND_MAP = BACKGROUND_PATH + "background_map";
public static final String BACKGROUND_SMALL_MAP = BACKGROUND_PATH + "background_small_map";
public static final String BACKGROUND_LARGE_MAP = BACKGROUND_PATH + "background_large_map";
public static final String BACKGROUND_ACTIONS = BACKGROUND_PATH + "background_actions";
public static final String OBJECTS_PATH = GFX_PATH + "objects/";
......
......@@ -284,7 +284,7 @@ public class Player extends Group {
}
private float getPlayerPositionYForTileMapPosition(int mapStartPositionY, TileMapPosition tileMapPosition) {
return mapStartPositionY + ((InTheDarknessGame.MAP_Y_SIZE - tileMapPosition.getPositionY() - 1) * InTheDarknessGame.TILE_SIZE) + (InTheDarknessGame.TILE_SIZE / 2) - (actualPlayerAnimatedImage.getHeight() / 2);
return mapStartPositionY + ((InTheDarknessGame.mapSizeY - tileMapPosition.getPositionY() - 1) * InTheDarknessGame.TILE_SIZE) + (InTheDarknessGame.TILE_SIZE / 2) - (actualPlayerAnimatedImage.getHeight() / 2);
}
private AnimatedImage createPlayerAnimatedImage(int width, int height, String animationName, int framesCount, InTheDarknessGame inTheDarknessGame) {
......
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.nic.tablexia.game.games.in_the_darkness.map;
import cz.nic.tablexia.game.games.in_the_darkness.assets.InTheDarknessAssets;
public enum InTheDarknessMap {
SMALL_MAP(InTheDarknessAssets.BACKGROUND_SMALL_MAP, 5, 6),
LARGE_MAP(InTheDarknessAssets.BACKGROUND_LARGE_MAP, 7, 6);
private String mapTexture;
private int sizeX;
private int sizeY;
InTheDarknessMap(String mapTexture, int sizeX, int sizeY) {
this.mapTexture = mapTexture;
this.sizeX = sizeX;
this.sizeY = sizeY;
}
public String getMapTexture() {
return mapTexture;
}
public int getSizeY() {
return sizeY;
}
public int getSizeX() {
return sizeX;
}
}
......@@ -142,7 +142,7 @@ public class MapGenerator implements IMapProvider {
if (lastEndTile == null) {
// create entry tile
startPosition = InTheDarknessGame.DEFAULT_MAP_START_POSITION;
startPosition = InTheDarknessGame.defaultMapStartPosition;
startTile = new Tile(TileType.getRandomTileTypeForAvailableDoors(null, true, null, null, true, randomAccess));
} else {
startPosition = lastEndTile.getTileMapPosition();
......@@ -324,7 +324,7 @@ public class MapGenerator implements IMapProvider {
private boolean generatePathFromPointToPoint(TileMap tileMap, TileMapPosition startPosition, TileMapPosition finishPosition, boolean useOnlyFreeTiles, boolean generateFinalTile, List<TileMapPosition> bannedPositions) {
int generatorMaxCycleCounter = 0;
int generatorMaxCycleCount = InTheDarknessGame.MAP_X_SIZE * InTheDarknessGame.MAP_Y_SIZE;
int generatorMaxCycleCount = InTheDarknessGame.mapSizeX * InTheDarknessGame.mapSizeY;
int lastXPosition = startPosition.getPositionX();
int lastYPosition = startPosition.getPositionY();
......
......@@ -35,7 +35,7 @@ public class MapTutorial implements IMapProvider {
public TileMap prepareMap(Tile lastFinishTile, int mapXSize, int mapYSize, MapObjectType finishMapObject, boolean hasKey) {
TileMap tileMap = new TileMap(mapXSize, mapYSize);
TileMapPosition position1 = InTheDarknessGame.DEFAULT_MAP_START_POSITION;
TileMapPosition position1 = InTheDarknessGame.defaultMapStartPosition;
TileMapPosition position2 = new TileMapPosition(position1.getPositionX() - 1, position1.getPositionY());
TileMapPosition position3 = new TileMapPosition(position1.getPositionX() - 1, position1.getPositionY() - 1);
tileMap.setMapStartPosition(position1);
......
......@@ -92,7 +92,7 @@ public class MapObject {
float tileImageWidth = tileImage.getWidth();
float tileImageHeight = tileImage.getHeight();
mapObjectImage.setPosition((tile.getMapPositionX() * tileImageWidth) + (tileImageWidth * mapObjectType.getXOffsetRatio()), (InTheDarknessGame.MAP_Y_SIZE * InTheDarknessGame.TILE_SIZE) - (((tile.getMapPositionY() + 1) * tileImageHeight) - (tileImageHeight * mapObjectType.getYOffsetRatio())));
mapObjectImage.setPosition((tile.getMapPositionX() * tileImageWidth) + (tileImageWidth * mapObjectType.getXOffsetRatio()), (InTheDarknessGame.mapSizeY * InTheDarknessGame.TILE_SIZE) - (((tile.getMapPositionY() + 1) * tileImageHeight) - (tileImageHeight * mapObjectType.getYOffsetRatio())));
if (getMapObjectType().isRotable()) {
mapObjectImage.setOrigin(Align.center);
mapObjectImage.setRotation(-tile.getTileType().getRotation() * QUARTER_ROTATION);
......
......@@ -98,7 +98,7 @@ public class MapObstacle {
float tileImageHeight = tileImage.getHeight();
image.setPosition((tile.getMapPositionX() * tileImageWidth) + offsetX + (image.getWidth() * getMapObstacleType().getCorrectionOffsetX()),
(InTheDarknessGame.MAP_Y_SIZE * InTheDarknessGame.TILE_SIZE) - ((tile.getMapPositionY() + 1) * tileImageHeight) + offsetY + (image.getHeight() * getMapObstacleType().getCorrectionOffsetY()));
(InTheDarknessGame.mapSizeY * InTheDarknessGame.TILE_SIZE) - ((tile.getMapPositionY() + 1) * tileImageHeight) + offsetY + (image.getHeight() * getMapObstacleType().getCorrectionOffsetY()));
image.setOrigin(Align.center);
image.setRotation(-mapObstacleType.getRotation() * QUARTER_ROTATION);
return image;
......
......@@ -192,7 +192,7 @@ public class Tile {
}
public TileMapPosition getTilePosition() {
return new TileMapPosition((mapPositionX * InTheDarknessGame.TILE_SIZE), (InTheDarknessGame.MAP_Y_SIZE * InTheDarknessGame.TILE_SIZE) - ((mapPositionY + 1) * InTheDarknessGame.TILE_SIZE));
return new TileMapPosition((mapPositionX * InTheDarknessGame.TILE_SIZE), (InTheDarknessGame.mapSizeY * InTheDarknessGame.TILE_SIZE) - ((mapPositionY + 1) * InTheDarknessGame.TILE_SIZE));
}
/**
......
......@@ -249,7 +249,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
private void stopRuleSound(float fadeoutTime) {
if (getRuleSound().isPlaying()) {
MusicUtil.fadeOut(getRuleSound(), fadeoutTime, true);
MusicUtil.fadeOut(getRuleSound(), fadeoutTime);
}
}
......
......@@ -27,6 +27,7 @@ import java.util.Random;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.kidnapping.generator.PathGenerator;
import cz.nic.tablexia.game.games.kidnapping.generator.SoundPathGenerator;
import cz.nic.tablexia.shared.model.resolvers.KidnappingScoreResolver;
import cz.nic.tablexia.util.ui.tilemapgenerator.Position;
import cz.nic.tablexia.game.games.kidnapping.generator.TileMapGenerator;
import cz.nic.tablexia.game.games.kidnapping.media.DirectionSounds;
......@@ -39,9 +40,9 @@ import cz.nic.tablexia.shared.model.Game;
* Created by lhoracek on 5/15/15.
*/
public class GameState {
public static final String GAME_MISSES = "GAME_MISSES";
public static final String GAME_REPLAYS = "GAME_REPLAYS";
public static final String GAME_STEP = "GAME_STEP";
public static final String GAME_MISSES = KidnappingScoreResolver.GAME_MISSES;
public static final String GAME_REPLAYS = KidnappingScoreResolver.GAME_REPLAYS;
public static final String GAME_STEP = KidnappingScoreResolver.GAME_STEP;
private final Map<Position, TileType> map;
......
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.nic.tablexia.game.games.kidnapping.util;
import java.util.ArrayList;
import java.util.List;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.kidnapping.Properties;
import cz.nic.tablexia.game.games.kidnapping.model.GameState;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.GameScore;
/**
* Created by lhoracek on 10/6/15.
*/
public class KidnappingResultResolver extends GameDefinition.GameResultResolver {
@Override
public AbstractTablexiaGame.GameResult getGameCupsResult(Game game) {
int[] levels = Properties.GAMERULE_CUPS[game.getGameDifficulty() - 1];
if (game.getGameScoreValue(GameState.GAME_MISSES) != null) {
int misses = Integer.valueOf(game.getGameScoreValue(GameState.GAME_MISSES));
if (misses <= levels[0]) {
return AbstractTablexiaGame.GameResult.THREE_STAR;
} else if (misses <= levels[1]) {
return AbstractTablexiaGame.GameResult.TWO_STAR;
} else if (misses <= levels[2]) {
return AbstractTablexiaGame.GameResult.ONE_STAR;
}
}
return AbstractTablexiaGame.GameResult.NO_STAR;
}
@Override
public float getGameScoreResult(Game game) {
return Float.parseFloat(game.getGameScore(GameState.GAME_MISSES, "0"));
}
@Override
public List<GameScore> getGameScoreList(GameDifficulty difficulty, AbstractTablexiaGame.GameResult result) {
int[] levels = Properties.GAMERULE_CUPS[difficulty.getDifficultyNumber() - 1];
int misses;
switch (result) {
case NO_STAR:
misses = levels[2] + 1;
break;
case ONE_STAR:
misses = levels[2];
break;
case TWO_STAR:
misses = levels[1];
break;
default:
misses = 0;
break;
}
List<GameScore> gameScores = new ArrayList<GameScore>(1);
gameScores.add(new GameScore(GameState.GAME_MISSES, Integer.toString(misses)));
return gameScores;
}
}
......@@ -19,66 +19,38 @@ package cz.nic.tablexia.game.games.night_watch.helper;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.shared.model.resolvers.NightWatchScoreResolver;
/**
* Created by Vendik on 30.4.2015.
* Edited by danilov on 3.8.2016.
*/
public class GameRulesHelper {
//time difference is divided by number of rounds in each level showing the same number of windows
private static final float STARTING_LID_TIME = 1.5f;
private static final float END_LID_TIME = 0.7f;
private static final int NUMBER_OF_LEVELS = 2;
public static final int NUMBER_OF_ROUNDS = 12;
public static final int ONE_STAR = NightWatchScoreResolver.ONE_STAR;
public static final int TWO_STARS = NightWatchScoreResolver.TWO_STARS;
public static final int THREE_STARS = NightWatchScoreResolver.THREE_STARS;