Skip to content
Snippets Groups Projects
Commit 3c32efd4 authored by Drahomír Karchňák's avatar Drahomír Karchňák
Browse files

#57 - Fixed annoying bug, which allowed you to click on a single arrow...

#57 - Fixed annoying bug, which allowed you to click on a single arrow multiple times getting more than one point for each crossroad...
parent d41e8d94
No related branches found
No related tags found
No related merge requests found
......@@ -64,7 +64,8 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
private static final float RULE_MESSAGE_FADE_OUT_TIME = 0.5f;
private static final float HELP_OVERLAY_FADE_IN_TIME = 0.5f;
private static final float MAP_FADE_IN_TIME = 0.5f;
private static final float GAME_DELAY_TIME = 0.5f;
private static final float GAME_DELAY = 0.5f;
private static final float GAME_PLAY_SOUNDS_DELAY = 0.5f;
private static final float MAP_SCALE = 0.5f;
private static final float CENTER_MAP_TIME = 0.7f;
......@@ -99,8 +100,12 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
map.addAction(CenterTileAction.getInstance(map.getTile(getData().getCurrentPosition())));
map.getReplayButton().addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
playSounds();
getData().addReplay();
if(map.getReplayButton().isActive()) {
playSounds();
getData().addReplay();
map.getReplayButton().setActive(false);
}
}
});
......@@ -138,7 +143,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
ruleMessage.addAction(new SequenceAction(Actions.fadeOut(RULE_MESSAGE_FADE_OUT_TIME), Actions.visible(false)));
map.addAction(Actions.sequence(Actions.delay(RULE_MESSAGE_FADE_OUT_TIME + GAME_DELAY_TIME),
map.addAction(Actions.sequence(Actions.delay(RULE_MESSAGE_FADE_OUT_TIME + GAME_DELAY),
Actions.run(new Runnable() {
public void run() {
startRound();
......@@ -193,6 +198,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
if(!ruleMessageShown) {
showRuleMessage();
}
//We may need this for mobile version
// else {
// map.addAction(Actions.sequence(Actions.delay(1),
// Actions.run(new Runnable() {
......@@ -220,7 +226,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
Actions.parallel( CenterTileAction.getInstance(map.getTile(getData().getCurrentPosition()), CENTER_MAP_TIME),
getData().getStep() != 0 ? ShowRoadAction.fadeIn(getData().getLastPosition(), getData().getLastDirectionFrom().getOppositeDirection()) : Actions.delay(0)),
ShowFlagAction.fadeIn(getData().getCurrentPosition()),
Actions.delay(0.5f),
Actions.delay(GAME_PLAY_SOUNDS_DELAY),
Actions.run(new Runnable() {
public void run() {
playSounds();
......@@ -242,15 +248,22 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
final Arrow[] arrows = map.getDirectionArrow(position, directions);
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())];
for (Arrow a : arrows) {
for (final Arrow a : arrows) {
for (EventListener el : a.getListeners()) {
a.removeListener(el);
}
a.addListener(new ClickListener() {
boolean clicked = false;
@Override
public void clicked(InputEvent event, float x, float y) {
if (event.getTarget() == correct) {
if(clicked) return;
clicked = true;
if (event.getTarget() == correct) {
map.addAction(Actions.sequence(CorrectAlphaAction.fadeIn(), CorrectAlphaAction.fadeOut(), ShowArrowAction.arrowsFadeOut(arrows), Actions.run(new Runnable() {
@Override
public void run() {
......@@ -262,6 +275,8 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
map.addAction(Actions.sequence(WrongAlphaAction.fadeIn(), WrongAlphaAction.fadeOut()));
wrong();
}
map.getReplayButton().setActive(false);
}
});
}
......
......@@ -12,11 +12,20 @@ public class ReplayButton extends TablexiaButton {
private static final String REPLAY_BUTTON_TEXT_KEY = "game_kidnapping_replay";
private static final int WIDTH = 200;
private static final int HEIGHT = 80;
private boolean active = true;
public ReplayButton(KidnappingGame screen) {
public ReplayButton(KidnappingGame screen) {
super(screen.getText(REPLAY_BUTTON_TEXT_KEY), ButtonType.GREEN);
setSize(WIDTH, HEIGHT);
setDisabled(true);
}
public void setActive(boolean active) {
this.active = active;
}
public boolean isActive() {
return active;
}
}
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