Commit baed8ac9 authored by Aneta Steimarova's avatar Aneta Steimarova

#865 Added music dispose for each sound in sequence for each level

parent f1dbca01
......@@ -18,6 +18,7 @@
package cz.nic.tablexia.game.games.safe;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Group;
......@@ -29,6 +30,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Scaling;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
......@@ -114,6 +116,7 @@ public class SafeGame extends AbstractTablexiaGame<Void> {
public int level_fails = 0;
private boolean paused = false;
private boolean isVisualisationVisible = false;
private List<Music> musicList;
public AbstractMechanics getSafeGroup() {
......@@ -167,6 +170,7 @@ public class SafeGame extends AbstractTablexiaGame<Void> {
round = 0;
score = 0;
level_fails = 0;
musicList = new ArrayList<Music>();
selectedLight = null;
usedHelpButton = false;
setGameScore(SCORE_COUNT, score);
......@@ -328,17 +332,33 @@ public class SafeGame extends AbstractTablexiaGame<Void> {
playSoundSequence(safeSequence);
makeButtonsTouchable();
} else {
disposeMusicInMusicList();
gameComplete();
}
}
private void prepareNextRound() {
disposeMusicInMusicList();
safeSequence = null;
selectedLight = null;
prepareSequenceMusic();
generateSafeForRound();
}
private void disposeMusicInMusicList(){
for(Music music: musicList){
music.dispose();
}
musicList.clear();
}
public void addMusicToMusicList(Music sound){
for(Music music: musicList){
if(music.equals(sound)) return;
}
musicList.add(sound);
}
private void addHelpBtn() {
helpButton = new ImageTablexiaButton(getText(SafeAssets.HELP_EYE_TEXT), new Image(getScreenTextureRegion(SafeAssets.HELP_BTN_EYE)), Align.left, StandardTablexiaButton.TablexiaButtonType.BLUE);
setButton(helpButton, getViewportWidth() - REPLAY_BUTTON_OFFSET_X, getSceneInnerTopY() - HELP_BUTTON_OFFSET_Y, new HelpButtonClickListener(this));
......
......@@ -18,6 +18,7 @@
package cz.nic.tablexia.game.games.safe.actors;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
......@@ -129,7 +130,9 @@ public class SequenceGenerator extends Group {
//actions to play !!!there always has to be only one in one level (but can be used more than one after reset)
List<Action> playMusicActionList = new ArrayList<Action>();
for (SafeSounds safeSound : safeSequence.getSoundsToSequence()) {
PlayMusicAction musicAction = PlayMusicAction.getInstance(safegame.getMusic(safeSound.getSoundPath()));
Music music = safegame.getMusic(safeSound.getSoundPath());
safegame.addMusicToMusicList(music);
PlayMusicAction musicAction = PlayMusicAction.getInstance(music);
musicAction.reset();
playMusicActionList.add(musicAction);
}
......
......@@ -26,7 +26,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import java.util.List;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.games.safe.SafeGame;
/**
* Created by Aneta Steimarová on 25.5.17.
......@@ -51,24 +51,26 @@ public class SafeLightImage extends Image {
return inputListener;
}
public SafeLightImage(AbstractTablexiaGame game, String greyTextureRegion, String redTextureRegion, String greenTextureRegion, String blueTextureRegion, Music music, float angle) {
super(game.getScreenTextureRegion(greyTextureRegion));
this.screenTextureGrey = game.getScreenTextureRegion(greyTextureRegion);
this.screenTextureRed = game.getScreenTextureRegion(redTextureRegion);
this.screenTextureGreen = game.getScreenTextureRegion(greenTextureRegion);
this.screenTextureBlue = game.getScreenTextureRegion(blueTextureRegion);
public SafeLightImage(SafeGame safeGame, String greyTextureRegion, String redTextureRegion, String greenTextureRegion, String blueTextureRegion, Music music, float angle) {
super(safeGame.getScreenTextureRegion(greyTextureRegion));
this.screenTextureGrey = safeGame.getScreenTextureRegion(greyTextureRegion);
this.screenTextureRed = safeGame.getScreenTextureRegion(redTextureRegion);
this.screenTextureGreen = safeGame.getScreenTextureRegion(greenTextureRegion);
this.screenTextureBlue = safeGame.getScreenTextureRegion(blueTextureRegion);
this.sound = music;
this.angle = angle;
safeGame.addMusicToMusicList(sound);
}
public SafeLightImage(AbstractTablexiaGame game, String greyTextureRegion, String redTextureRegion, String greenTextureRegion, String blueTextureRegion, Music music) {
super(game.getScreenTextureRegion(greyTextureRegion));
this.screenTextureGrey = game.getScreenTextureRegion(greyTextureRegion);
this.screenTextureRed = game.getScreenTextureRegion(redTextureRegion);
this.screenTextureGreen = game.getScreenTextureRegion(greenTextureRegion);
this.screenTextureBlue = game.getScreenTextureRegion(blueTextureRegion);
public SafeLightImage(SafeGame safeGame, String greyTextureRegion, String redTextureRegion, String greenTextureRegion, String blueTextureRegion, Music music) {
super(safeGame.getScreenTextureRegion(greyTextureRegion));
this.screenTextureGrey = safeGame.getScreenTextureRegion(greyTextureRegion);
this.screenTextureRed = safeGame.getScreenTextureRegion(redTextureRegion);
this.screenTextureGreen = safeGame.getScreenTextureRegion(greenTextureRegion);
this.screenTextureBlue = safeGame.getScreenTextureRegion(blueTextureRegion);
this.sound = music;
this.angle = DEFAULT_ANGLE;
safeGame.addMusicToMusicList(sound);
}
public Music getSound() {
......
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