Commit b93fb246 authored by Aneta Steimarova's avatar Aneta Steimarova

#865 Made dilay after play each sound in sequence bonus

parent baed8ac9
...@@ -57,6 +57,7 @@ public class SequenceGenerator extends Group { ...@@ -57,6 +57,7 @@ public class SequenceGenerator extends Group {
private static final Color NORMAL_COLOR = Color.BLACK; private static final Color NORMAL_COLOR = Color.BLACK;
private static final float SILENCE_DELAY = 2f; private static final float SILENCE_DELAY = 2f;
private static final float SEQUENCE_DELAY = 1f; private static final float SEQUENCE_DELAY = 1f;
private static final float BONUS_DELAY = 0.75f;
private Image earImage, backgroundImage; private Image earImage, backgroundImage;
private TablexiaLabel text; private TablexiaLabel text;
...@@ -114,13 +115,13 @@ public class SequenceGenerator extends Group { ...@@ -114,13 +115,13 @@ public class SequenceGenerator extends Group {
int charNum = 0; int charNum = 0;
//generated sequence //generated sequence
for (SafeSounds safeSequenceSound : safeSequence.getGeneratedSoundSequence()) { for (SafeSounds safeSequenceSound : safeSequence.getGeneratedSoundSequence()) {
charNum = addSound(sa, safeSequenceSound, charNum, listOfChars, playMusicActionList, safeSequence); charNum = addSound(sa, safeSequenceSound, charNum, listOfChars, playMusicActionList, safeSequence, safegame);
} }
//repeat first x sounds //repeat first x sounds
for (int i = 0; i < safeSequence.getPlayAgainFirstXSounds(); i++) { for (int i = 0; i < safeSequence.getPlayAgainFirstXSounds(); i++) {
SafeSounds safeSound = safeSequence.getGeneratedSoundSequence()[i]; SafeSounds safeSound = safeSequence.getGeneratedSoundSequence()[i];
charNum = addSound(sa, safeSound, charNum, listOfChars, playMusicActionList, safeSequence); charNum = addSound(sa, safeSound, charNum, listOfChars, playMusicActionList, safeSequence, safegame);
} }
Log.info("Sequence Generator", soundSequence); Log.info("Sequence Generator", soundSequence);
return sa; return sa;
...@@ -140,23 +141,23 @@ public class SequenceGenerator extends Group { ...@@ -140,23 +141,23 @@ public class SequenceGenerator extends Group {
} }
private static int addSound(SequenceAction sa, SafeSounds safeSequenceSound, int charNum, List<Actor> listOfChars, List<Action> playMusicActionList, SafeSequence safeSequence) { private static int addSound(SequenceAction sa, SafeSounds safeSequenceSound, int charNum, List<Actor> listOfChars, List<Action> playMusicActionList, SafeSequence safeSequence, SafeGame safegame) {
if (safeSequenceSound.equals(SafeSounds.SILENCE)) { if (safeSequenceSound.equals(SafeSounds.SILENCE)) {
sa.addAction(Actions.delay(SILENCE_DELAY)); sa.addAction(Actions.delay(SILENCE_DELAY));
soundSequence += " - "; soundSequence += " - ";
} else { } else {
soundSequence += safeSequenceSound.toString() + " "; soundSequence += safeSequenceSound.toString() + " ";
if (listOfChars != null) if (listOfChars != null)
addActionToSequence(safeSequenceSound, sa, playMusicActionList, safeSequence, listOfChars.get(charNum)); addActionToSequence(safeSequenceSound, sa, playMusicActionList, safeSequence, listOfChars.get(charNum), safegame);
else else
addActionToSequence(safeSequenceSound, sa, playMusicActionList, safeSequence, null); addActionToSequence(safeSequenceSound, sa, playMusicActionList, safeSequence, null, safegame);
charNum++; charNum++;
} }
return charNum; return charNum;
} }
private static void addActionToSequence(SafeSounds safeSequenceSound, SequenceAction sa, List<Action> playMusicActionList, SafeSequence safeSequence, Actor character) { private static void addActionToSequence(SafeSounds safeSequenceSound, SequenceAction sa, List<Action> playMusicActionList, SafeSequence safeSequence, Actor character, SafeGame safegame) {
Action playMusicAction = findActionForSafeSound(safeSequenceSound, playMusicActionList, safeSequence); Action playMusicAction = findActionForSafeSound(safeSequenceSound, playMusicActionList, safeSequence);
if (playMusicAction == null) if (playMusicAction == null)
Log.err("ERROR", "Well...this should not happen. Try to look at addActionToSequence method in SequenceGenerator."); Log.err("ERROR", "Well...this should not happen. Try to look at addActionToSequence method in SequenceGenerator.");
...@@ -175,6 +176,9 @@ public class SequenceGenerator extends Group { ...@@ -175,6 +176,9 @@ public class SequenceGenerator extends Group {
} }
})); }));
sa.addAction(playMusicAction); sa.addAction(playMusicAction);
if (safegame.getGameDifficulty().equals(GameDifficulty.BONUS)){
sa.addAction(Actions.delay(BONUS_DELAY));
}
if (character != null) { if (character != null) {
sa.addAction(Actions.run(new Runnable() { sa.addAction(Actions.run(new Runnable() {
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment