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

Merge branch 'feature-kidnapping' into 'devel'

Feature kidnapping



See merge request !158
parents c16a610b 9395ffdf
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
@Override
protected void gameLoaded(final java.util.Map<String, String> gameState) {
getStage().clear();
getStage().addActor(map = Map.MapFactory.createInstance(this, gfxLibrary, getData()));
map.setMapScale(MAP_SCALE);
......@@ -113,6 +114,10 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
prepareRuleMessage();
//Resets stats to 0
getData().resetMisses();
getData().resetReplays();
screenResized(0, 0);
}
......@@ -197,6 +202,14 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
if(!ruleMessageShown) {
showRuleMessage();
}
else {
map.addAction(Actions.sequence(Actions.delay(RULE_MESSAGE_FADE_OUT_TIME + GAME_DELAY),
Actions.run(new Runnable() {
public void run() {
startRound();
}
})));
}
}
@Override
......@@ -235,15 +248,17 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
public void run() {
Music[] sounds = soundPack.getSoundsInOrder(KidnappingGame.this, directions, getData().getNextDirection());
final Arrow[] arrows = map.getDirectionArrow(position, directions);
for (final Arrow a : arrows) {
for (EventListener el : a.getListeners()) {
a.removeListener(el);
}
}
map.addAction(Actions.sequence(ShowArrowAction.arrowsFadeIn(arrows), Actions.delay(0.5f), ArrowMusicAction.arrowSequence(sounds, arrows), ReplayAlphaAction.fadeIn(), Actions.run(new Runnable() {
public void run() {
map.getReplayButton().setActive(true);
final Arrow correct = arrows[(getData().getStep() == getData().getPath().size() - 1) ? getRandom().nextInt(arrows.length) : DirectionsHelper.getNextDirectionIndex(directions, getData().getNextDirection())];
final Arrow correct = arrows[DirectionsHelper.getNextDirectionIndex(directions, getData().getNextDirection())];
for (final Arrow a : arrows) {
for (EventListener el : a.getListeners()) {
a.removeListener(el);
}
a.addListener(new ClickListener() {
boolean clicked = false;
......@@ -253,19 +268,19 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
clicked = true;
if (event.getTarget() == correct) {
map.addAction(Actions.sequence(CorrectAlphaAction.fadeIn(), CorrectAlphaAction.fadeOut(), ShowArrowAction.arrowsFadeOut(arrows), Actions.run(new Runnable() {
map.addAction(Actions.sequence(CorrectAlphaAction.fadeIn(), CorrectAlphaAction.fadeOut(), ShowArrowAction.arrowsFadeOut(arrows), Actions.run(new Runnable() {
@Override
public void run() {
correct();
}
})));
} else {
sfxLibrary.getSound(SoundType.SOUND_ERROR).play();
map.addAction(Actions.sequence(WrongAlphaAction.fadeIn(), WrongAlphaAction.fadeOut()));
wrong();
}
map.getReplayButton().setActive(false);
} else {
sfxLibrary.getSound(SoundType.SOUND_ERROR).play();
map.addAction(Actions.sequence(WrongAlphaAction.fadeIn(), WrongAlphaAction.fadeOut()));
wrong();
}
map.getReplayButton().setActive(false);
}
});
}
......
......@@ -78,6 +78,14 @@ public class GameState {
game.setGameScore(GAME_MISSES, String.valueOf(getMisses() + 1));
}
public void resetMisses() {
game.setGameScore(GAME_MISSES, String.valueOf(0));
}
public void resetReplays() {
game.setGameScore(GAME_REPLAYS, String.valueOf(0));
}
public int getMisses() {
return Integer.parseInt(game.getGameScore(GAME_MISSES, "0"));
}
......
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