diff --git a/core/assets/common/game/robbery/steps_female_in_1.mp3 b/core/assets/common/game/robbery/steps_female_in_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..f2b1825203c51a58b5b78f90ddd3591ebdc6ae8a Binary files /dev/null and b/core/assets/common/game/robbery/steps_female_in_1.mp3 differ diff --git a/core/assets/common/game/robbery/steps_female_in_2.mp3 b/core/assets/common/game/robbery/steps_female_in_2.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..42bd2f67772c181e174e7b3ffc9b008e1a9ddb43 Binary files /dev/null and b/core/assets/common/game/robbery/steps_female_in_2.mp3 differ diff --git a/core/assets/common/game/robbery/steps_female_out_1.mp3 b/core/assets/common/game/robbery/steps_female_out_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..dd5907b8d7d51dd44222da149bdc8720a2b64c7b Binary files /dev/null and b/core/assets/common/game/robbery/steps_female_out_1.mp3 differ diff --git a/core/assets/common/game/robbery/steps_female_out_2.mp3 b/core/assets/common/game/robbery/steps_female_out_2.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..4ab53c523e252f372efa2da0160704f346d2de1c Binary files /dev/null and b/core/assets/common/game/robbery/steps_female_out_2.mp3 differ diff --git a/core/assets/common/game/robbery/steps_male_in_1.mp3 b/core/assets/common/game/robbery/steps_male_in_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..8f6db0b79306de57cdded162c16f7b7d190f9ba7 Binary files /dev/null and b/core/assets/common/game/robbery/steps_male_in_1.mp3 differ diff --git a/core/assets/common/game/robbery/steps_male_in_2.mp3 b/core/assets/common/game/robbery/steps_male_in_2.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..a8a83752345fb6bab412788c829bf6e329af0952 Binary files /dev/null and b/core/assets/common/game/robbery/steps_male_in_2.mp3 differ diff --git a/core/assets/common/game/robbery/steps_male_in_3.mp3 b/core/assets/common/game/robbery/steps_male_in_3.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..b6e2528f9697cefa61757e437d8e6f7b0d08ceff Binary files /dev/null and b/core/assets/common/game/robbery/steps_male_in_3.mp3 differ diff --git a/core/assets/common/game/robbery/steps_male_out_1.mp3 b/core/assets/common/game/robbery/steps_male_out_1.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..42a3157e1263092649d8dc990ec4bae16d379121 Binary files /dev/null and b/core/assets/common/game/robbery/steps_male_out_1.mp3 differ diff --git a/core/assets/common/game/robbery/steps_male_out_2.mp3 b/core/assets/common/game/robbery/steps_male_out_2.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..f75b61fa7752a9d857680ac6495ea2ed93f38962 Binary files /dev/null and b/core/assets/common/game/robbery/steps_male_out_2.mp3 differ diff --git a/core/assets/common/game/robbery/steps_male_out_3.mp3 b/core/assets/common/game/robbery/steps_male_out_3.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..85dc7f36113515b258ec9c7997d41488f644f1ac Binary files /dev/null and b/core/assets/common/game/robbery/steps_male_out_3.mp3 differ diff --git a/core/src/cz/nic/tablexia/game/AbstractTablexiaGame.java b/core/src/cz/nic/tablexia/game/AbstractTablexiaGame.java index 1ce55e17bed50e64f9d51404d457256aede0ac93..e28d919413651a218c0276bc7694730d2a3c8e9a 100644 --- a/core/src/cz/nic/tablexia/game/AbstractTablexiaGame.java +++ b/core/src/cz/nic/tablexia/game/AbstractTablexiaGame.java @@ -288,7 +288,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T> } } - protected TablexiaRandom getRandom() { + public TablexiaRandom getRandom() { return random; } diff --git a/core/src/cz/nic/tablexia/game/games/robbery/AbstractRobberyScreen.java b/core/src/cz/nic/tablexia/game/games/robbery/AbstractRobberyScreen.java index 59aee70b6a1450fa9682cbd6fb1ea20e02feef69..2264e0e008e179a5cea8c1ebf1a0001d3f0bca6e 100644 --- a/core/src/cz/nic/tablexia/game/games/robbery/AbstractRobberyScreen.java +++ b/core/src/cz/nic/tablexia/game/games/robbery/AbstractRobberyScreen.java @@ -3,6 +3,8 @@ package cz.nic.tablexia.game.games.robbery; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import java.util.Random; + import cz.nic.tablexia.game.difficulty.GameDifficulty; import cz.nic.tablexia.game.games.robbery.rules.GameRule; import cz.nic.tablexia.game.games.robbery.rules.GameRulesDefinition; @@ -57,6 +59,10 @@ public abstract class AbstractRobberyScreen extends AbstractTablexiaScreen<GameR //////////////////////////// GAME DATA ACCESS + protected Random getRandom() { + return robberyGame.getRandom(); + } + @Override public GameRule getData() { return robberyGame.getData(); diff --git a/core/src/cz/nic/tablexia/game/games/robbery/GameScreen.java b/core/src/cz/nic/tablexia/game/games/robbery/GameScreen.java index 4e6e179be0638f097f7f4e54f2807610256f6df4..dff3db0e32eb437ba5d232a72e48ed7c17149c41 100644 --- a/core/src/cz/nic/tablexia/game/games/robbery/GameScreen.java +++ b/core/src/cz/nic/tablexia/game/games/robbery/GameScreen.java @@ -1,17 +1,22 @@ package cz.nic.tablexia.game.games.robbery; +import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Interpolation; +import com.badlogic.gdx.scenes.scene2d.Action; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.Touchable; +import com.badlogic.gdx.scenes.scene2d.actions.RunnableAction; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; import com.badlogic.gdx.utils.Align; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Random; import cz.nic.tablexia.game.difficulty.GameDifficulty; import cz.nic.tablexia.game.games.robbery.assets.RobberyAssets; @@ -58,8 +63,7 @@ public class GameScreen extends AbstractRobberyScreen { infoItemGroup.addActor(infoItem); infoItemGroup.addActor(infoItemTitle); if (color != null) { - infoBanner = new Image(abstractRobberyScreen.getScreenTextureRegion(RobberyAssets.CREATURE_BACKGROUND_TEXTURE)); - infoBanner.setColor(color); + infoBanner = new Image(abstractRobberyScreen.getColorTextureRegion(color)); } } @@ -175,6 +179,43 @@ public class GameScreen extends AbstractRobberyScreen { return null; } } + + public enum StepSound { + + FEMALE_1(CreatureRoot.AttributeGender.FEMALE, RobberyAssets.SOUND_STEPS_FEMALE_1_IN, RobberyAssets.SOUND_STEPS_FEMALE_1_OUT), + FEMALE_2(CreatureRoot.AttributeGender.FEMALE, RobberyAssets.SOUND_STEPS_FEMALE_2_IN, RobberyAssets.SOUND_STEPS_FEMALE_2_OUT), + MALE_1 (CreatureRoot.AttributeGender.MALE, RobberyAssets.SOUND_STEPS_MALE_1_IN, RobberyAssets.SOUND_STEPS_MALE_1_OUT), + MALE_2 (CreatureRoot.AttributeGender.MALE, RobberyAssets.SOUND_STEPS_MALE_2_IN, RobberyAssets.SOUND_STEPS_MALE_2_OUT), + MALE_3 (CreatureRoot.AttributeGender.MALE, RobberyAssets.SOUND_STEPS_MALE_3_IN, RobberyAssets.SOUND_STEPS_MALE_3_OUT); + + private final CreatureRoot.AttributeGender gender; + private final String soundIn; + private final String soundOut; + + StepSound(CreatureRoot.AttributeGender gender, String soundIn, String soundOut) { + this.gender = gender; + this.soundIn = soundIn; + this.soundOut = soundOut; + } + + public String getSoundIn() { + return soundIn; + } + + public String getSoundOut() { + return soundOut; + } + + public static StepSound getRandomStepSoundForGender(Random random, CreatureRoot.AttributeGender gender) { + List<StepSound> genderStepSounds = new ArrayList<StepSound>(); + for (StepSound stepSound: StepSound.values()) { + if (stepSound.gender == gender) { + genderStepSounds.add(stepSound); + } + } + return genderStepSounds.size() == 0 ? null : genderStepSounds.get(random.nextInt(genderStepSounds.size())); + } + } private static final Color COLOR_OK = Color.valueOf("39b54aff"); private static final Color COLOR_KO = Color.valueOf("c1272dff"); @@ -203,6 +244,11 @@ public class GameScreen extends AbstractRobberyScreen { private final static Interpolation CREATURE_START_INTERPOLATION = Interpolation.pow4Out; private final static Interpolation CREATURE_MIDDLE_INTERPOLATION = Interpolation.pow4In; private final static Interpolation CREATURE_FINISH_INTERPOLATION = Interpolation.linear; + + private static final int STEP_SOUND_INITIAL_SPEED = 1; + private static final float STEP_SOUND_SPEED_ADD_RATIO = 1f/2; + private static final int STEP_SOUND_IN_VOLUME = 1; + private static final float STEP_SOUND_OUT_VOLUME = 0.3f; private final Group colorInfoLayer = new Group(); private final Group creatureLayer = new Group(); @@ -279,7 +325,11 @@ public class GameScreen extends AbstractRobberyScreen { private float getCreatureMoveDurationForCreatureNumber(int creatureNumber) { return CREATURE_STRAT_MOVE_DURATION - (CREATURE_MOVE_DURATION_STEP * creatureNumber); } - + + private float getCreatureSoundSppedForCreatureNumber(float creatureNumber, float creaturesCount) { + return STEP_SOUND_INITIAL_SPEED + ((creatureNumber / creaturesCount) * STEP_SOUND_SPEED_ADD_RATIO); + } + private void prepareCreaturePositions(float viewportWidth, float viewportHeight) { creatureMiddle1PositionX = (viewportWidth / 5) * 3; creatureMiddle1PositionY = ((viewportHeight / 8)); @@ -290,6 +340,16 @@ public class GameScreen extends AbstractRobberyScreen { creatureFinishPositionX = 0; creatureFinishPositionY = creatureStartPositionY; } + + private Action playSound(final Sound sound, final float speed, final float volume) { + RunnableAction playSoundAction = run(new Runnable() { + @Override + public void run() { + sound.play(volume, speed, 0); + } + }); + return playSoundAction; + } private void showNextCreature(final List<CreatureRoot> creatures) { if ((getActualCreatureNumber() < creatures.size()) && (getNumberOfMistakesInGame() < 3)) { @@ -319,13 +379,17 @@ public class GameScreen extends AbstractRobberyScreen { } }; - creature.addListener(inputListener); - creature.addAction(sequence(parallel(moveTo(creatureMiddle1PositionX, creatureMiddle1PositionY, duration, CREATURE_START_INTERPOLATION), + final StepSound stepSound = StepSound.getRandomStepSoundForGender(getRandom(), creature.getAttributeGender()); + float soundSpeed = getCreatureSoundSppedForCreatureNumber(getActualCreatureNumber(), creatures.size()); + creature.addListener(inputListener); + creature.addAction(sequence(parallel(playSound(getSound(stepSound.getSoundIn()), soundSpeed, STEP_SOUND_IN_VOLUME), + moveTo(creatureMiddle1PositionX, creatureMiddle1PositionY, duration, CREATURE_START_INTERPOLATION), scaleTo(CREATURE_TO_SCALE, CREATURE_TO_SCALE, duration, CREATURE_START_INTERPOLATION)), - parallel(moveTo(creatureMiddle2PositionX, creatureMiddle2PositionY, duration * CREATURE_MIDDLE_DELAY_MODIFIER, CREATURE_MIDDLE_INTERPOLATION), + parallel(playSound(getSound(stepSound.getSoundOut()), soundSpeed, STEP_SOUND_OUT_VOLUME), + moveTo(creatureMiddle2PositionX, creatureMiddle2PositionY, duration * CREATURE_MIDDLE_DELAY_MODIFIER, CREATURE_MIDDLE_INTERPOLATION), scaleTo(CREATURE_FINAL_SCALE, CREATURE_FINAL_SCALE, duration * CREATURE_MIDDLE_DELAY_MODIFIER, CREATURE_MIDDLE_INTERPOLATION), run(new Runnable() { - + @Override public void run() { InfoItem.ALARM.hide(); @@ -333,7 +397,7 @@ public class GameScreen extends AbstractRobberyScreen { })), parallel(moveTo(creatureFinishPositionX, creatureFinishPositionY, duration * CREATURE_FINISH_DELAY_MODIFIER, CREATURE_FINISH_INTERPOLATION), run(new Runnable() { - + @Override public void run() { //do not touch behind window @@ -348,15 +412,15 @@ public class GameScreen extends AbstractRobberyScreen { setActualCreatureNumber(getActualCreatureNumber() + 1); showNextCreature(creatures); } - } + } })), run(new Runnable() { - - @Override - public void run() { - creature.remove(); - } - }))); + + @Override + public void run() { + creature.remove(); + } + }))); creatureLayer.addActor(creature); diff --git a/core/src/cz/nic/tablexia/game/games/robbery/RobberyGame.java b/core/src/cz/nic/tablexia/game/games/robbery/RobberyGame.java index 4889e66baaf9dcb5904e8b9865fce2cb5f6662ef..a7b2e5380dee10a9e856706f0984064211f4b553 100644 --- a/core/src/cz/nic/tablexia/game/games/robbery/RobberyGame.java +++ b/core/src/cz/nic/tablexia/game/games/robbery/RobberyGame.java @@ -42,6 +42,16 @@ public class RobberyGame extends AbstractTablexiaGame<GameRule> { soundsFileNames.add(RobberyAssets.SOUND_ALARM); soundsFileNames.add(RobberyAssets.SOUND_ERROR); soundsFileNames.add(RobberyAssets.SOUND_CHAINS); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_FEMALE_1_IN); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_FEMALE_1_OUT); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_FEMALE_2_IN); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_FEMALE_2_OUT); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_MALE_1_IN); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_MALE_1_OUT); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_MALE_2_IN); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_MALE_2_OUT); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_MALE_3_IN); + soundsFileNames.add(RobberyAssets.SOUND_STEPS_MALE_3_OUT); } @Override diff --git a/core/src/cz/nic/tablexia/game/games/robbery/assets/RobberyAssets.java b/core/src/cz/nic/tablexia/game/games/robbery/assets/RobberyAssets.java index 84b8e1798f1f4f4ca43a8324c46f7bb3fc5740c0..41845a6411abcb5587a0230ad440c6479aab13b0 100644 --- a/core/src/cz/nic/tablexia/game/games/robbery/assets/RobberyAssets.java +++ b/core/src/cz/nic/tablexia/game/games/robbery/assets/RobberyAssets.java @@ -8,6 +8,17 @@ public final class RobberyAssets { public static final String SOUND_ALARM = "alarm.mp3"; public static final String SOUND_ERROR = "error.mp3"; public static final String SOUND_CHAINS = "chains.mp3"; + + public static final String SOUND_STEPS_FEMALE_1_IN = "steps_female_in_1.mp3"; + public static final String SOUND_STEPS_FEMALE_1_OUT = "steps_female_out_1.mp3"; + public static final String SOUND_STEPS_FEMALE_2_IN = "steps_female_in_2.mp3"; + public static final String SOUND_STEPS_FEMALE_2_OUT = "steps_female_out_2.mp3"; + public static final String SOUND_STEPS_MALE_1_IN = "steps_male_in_1.mp3"; + public static final String SOUND_STEPS_MALE_1_OUT = "steps_male_out_1.mp3"; + public static final String SOUND_STEPS_MALE_2_IN = "steps_male_in_2.mp3"; + public static final String SOUND_STEPS_MALE_2_OUT = "steps_male_out_2.mp3"; + public static final String SOUND_STEPS_MALE_3_IN = "steps_male_in_3.mp3"; + public static final String SOUND_STEPS_MALE_3_OUT = "steps_male_out_3.mp3"; public static final String SCREEN_PATH = "gamescreen/";