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

Merge branch 'feature-kidnapping' into 'devel'

Feature kidnapping



See merge request !174
parents cb3e739d 719eaca1
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ game_kidnapping_replay=Přehrát znovu
game_kidnapping_rulemessage_understand=Rozumím
game_kidnapping_result_0=Je to bída, ale kdo říká, že\u00A0by ses nemohl zlepšit?
game_kidnapping_result_1=S čistýma ušima a trochou tréninku to jistě dotáhneš dál!
game_kidnapping_result_2=Dobré uši detektiovi sluší!
game_kidnapping_result_2=Dobré uši detektivovi sluší!
game_kidnapping_result_3=S takovýmhle sluchem si můžeš ve městě vykračovat poslepu!
game_kidnapping_instructions_silence=Pššššt!
......
......@@ -2,7 +2,7 @@ game_kidnapping_replay=Prehrať znova
game_kidnapping_rulemessage_understand=Rozumiem
game_kidnapping_result_0=Je to bieda, ale kto hovorí, že by si sa eště nemohol zlepšiť?
game_kidnapping_result_1=S čistými ušami a trochou tréningu to určite dotiahneš ďalej!
game_kidnapping_result_2=Dobré uši detektívovi pristanú!
game_kidnapping_result_2=Héj! Ten detektív má bystrý sluch!
game_kidnapping_result_3=S takým sluchom si môžeš v meste vykračovať poslepiačky!
game_kidnapping_instructions_silence=Pššššt!
......
......@@ -243,16 +243,17 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
final Position position = getData().getCurrentPosition();
final DirectionSounds.SoundPack soundPack = getData().getSounds().get(getData().getStep());
final Direction[] directions = DirectionsHelper.getNextDirections(getData().getLastDirectionFrom());
final Arrow[] arrows = map.getDirectionArrow(position, directions);
for (final Arrow a : arrows) {
for (EventListener el : a.getListeners()) {
a.removeListener(el);
}
}
map.addAction(Actions.sequence(ReplayAlphaAction.fadeOut(), new PlayExample(soundPack.getExample(this)), Actions.run(new Runnable() {
@Override
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);
......@@ -260,14 +261,16 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
final Arrow correct = arrows[DirectionsHelper.getNextDirectionIndex(directions, getData().getNextDirection())];
for (final Arrow a : arrows) {
a.addListener(new ClickListener() {
boolean clicked = false;
@Override
public void clicked(InputEvent event, float x, float y) {
if(clicked) return;
clicked = true;
if(a.isDisabled()) return;
a.setDisabled(true);
if (event.getTarget() == correct) {
//Disables all arrows
for (final Arrow arr : arrows) {
arr.setDisabled(true);
}
map.addAction(Actions.sequence(CorrectAlphaAction.fadeIn(), CorrectAlphaAction.fadeOut(), ShowArrowAction.arrowsFadeOut(arrows), Actions.run(new Runnable() {
@Override
public void run() {
......
......@@ -10,6 +10,7 @@ import com.badlogic.gdx.utils.Pool;
*/
public class PlayMusicAction extends Action {
private boolean finished = false;
private boolean played = false;
private Music music;
@Override
......@@ -34,6 +35,7 @@ public class PlayMusicAction extends Action {
@Override
public void onCompletion(Music music) {
finished = true;
played = false;
}
});
}
......@@ -42,8 +44,9 @@ public class PlayMusicAction extends Action {
public boolean act(float delta) {
Pool pool = getPool();
setPool(null); // Ensure this action can't be returned to the pool while executing.
if (!finished && !music.isPlaying()) {
music.play();
if (!finished && !music.isPlaying() && !played) {
music.play();
played = true;
}
setPool(pool);
return finished;
......
......@@ -31,6 +31,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Stack;
*/
public class Arrow extends Stack {
private Image normal, pressed;
private boolean disabled = false;
public Arrow(TextureRegion arrow, TextureRegion arrowPressed) {
addActor(pressed = new Image(arrowPressed));
......@@ -43,6 +44,14 @@ public class Arrow extends Stack {
normal.setVisible(true);
}
public void setDisabled(boolean val) {
this.disabled = val;
}
public boolean isDisabled() {
return disabled;
}
@Override
public Actor hit(float x, float y, boolean touchable) {
return super.hit(x, y, touchable) == null ? null : this;
......
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