Commit c55682cc authored by Anton Danilov's avatar Anton Danilov Committed by Anton Danilov

#322 Created overlay with ear when playing sounds, cleaned code

parent 69e7d060
......@@ -82,9 +82,9 @@ game_in_the_darkness_description=Procvičování seriality
game_in_the_darkness_preloader1=Naplánuj krok za krokem průchod labyrintem.
game_in_the_darkness_preloader2=Přetahuj správné úkony do pásu vpravo a\u00A0dávej pozor na všechny překážky. Teprve až budeš mít naplánovanou celou trasu, stiskni tlačítko HOTOVO.
game_crime_scene_title="Místo činu"
game_crime_scene_description="*Popis hry Místo činu*"
game_crime_scene_preloader="*Popis pravidla hry*"
game_crime_scene_title=Místo činu
game_crime_scene_description=*Popis hry Místo činu*
game_crime_scene_preloader=*Popis pravidla hry*
# <!-- Robbery -->
robbery_1_finished=Pouta standard
......
......@@ -82,9 +82,9 @@ game_in_the_darkness_description=Training der Serialität
game_in_the_darkness_preloader1=Plane Schritt für Schritt den\u00A0Weg duch das\u00A0Labyrinth.
game_in_the_darkness_preloader2=Ziehe die\u00A0richtigen Handlungen auf die\u00A0rechte Seite und\u00A0pass auf alle Hindernisse auf. Sobald du die\u00A0ganze Route geplant hast, drücke den\u00A0Knopf FERTIG.
game_crime_scene_title="*DE*Místo činu"
game_crime_scene_description="*DE* *Popis hry Místo činu*"
game_crime_scene_preloader="*DE* *Popis pravidla hry*"
game_crime_scene_title=*DE*Místo činu
game_crime_scene_description=*DE* *Popis hry Místo činu*
game_crime_scene_preloader=*DE* *Popis pravidla hry*
# <!-- Robbery -->
robbery_1_finished=Handschellen Standard
......
......@@ -84,9 +84,9 @@ game_in_the_darkness_description=Precvičovanie seriality
game_in_the_darkness_preloader1=Naplánuj krok za krokom prechod labyrintom.
game_in_the_darkness_preloader2=Preťahuj správne úkony do pásu vpravo a\u00A0dávaj pozor na všetky prekážky. Až keď budeš mať naplánovanú celú trasu, stlač tlačítko HOTOVO.
game_crime_scene_title="*SK* Místo činu"
game_crime_scene_description="*SK* * Popis hry Místo činu*"
game_crime_scene_preloader="*SK *Popis pravidla hry*"
game_crime_scene_title=*SK* Místo činu
game_crime_scene_description=*SK* *Popis hry Místo činu*
game_crime_scene_preloader=*SK *Popis pravidla hry*
# <!-- Robbery -->
robbery_1_finished=Púta štandard
......
......@@ -3,4 +3,5 @@ score_0=*CS* 0 star text
score_1=*CS* 1 star text
score_2=*CS* 2 star text
score_3=*CS* 3 star text
result_errors_count=Počet chyb: [BLACK]{0}[]
\ No newline at end of file
result_errors_count=Počet chyb: [BLACK]{0}[]
game_kidnapping_instructions_pay_attention=Pozorně poslouchej a zapamatuj si pořadí zvuků!
\ No newline at end of file
......@@ -3,4 +3,5 @@ score_0=*DE* 0 star text
score_1=*DE* 1 star text
score_2=*DE* 2 star text
score_3=*DE* 3 star text
result_errors_count=Fehleranzahl: [BLACK]{0}[]
\ No newline at end of file
result_errors_count=Fehleranzahl: [BLACK]{0}[]
game_kidnapping_instructions_pay_attention=*DE* Pozorně poslouchej a zapamatuj si pořadí zvuků!
\ No newline at end of file
......@@ -3,4 +3,5 @@ score_0=*SK* 0 star text
score_1=*SK* 1 star text
score_2=*SK* 2 star text
score_3=*SK* 3 star text
result_errors_count=Počet chýb\: [BLACK]{0}[]
\ No newline at end of file
result_errors_count=Počet chýb\: [BLACK]{0}[]
game_kidnapping_instructions_pay_attention=*SK* Pozorně poslouchej a zapamatuj si pořadí zvuků!
\ No newline at end of file
package cz.nic.tablexia.game.games.crime_scene;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
......@@ -23,6 +24,8 @@ import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.crime_scene.assets.CrimeSceneAssets;
import cz.nic.tablexia.game.games.kidnapping.actions.CenterTileAction;
import cz.nic.tablexia.util.ui.EarOverlay;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.util.ui.actionwidget.Action;
import cz.nic.tablexia.util.ui.actionwidget.ActionContainer;
import cz.nic.tablexia.util.ui.button.StandardTablexiaButton;
......@@ -67,6 +70,7 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> im
private GfxLibrary gfxLibrary = new GfxLibrary(this, CrimeSceneTileType.values());
private CrimeSceneMap map;
private TablexiaButton startButton;
private EarOverlay ear;
private List<ActionContainer> selectedActions;
private int selectedActionPosition = 0;
......@@ -114,11 +118,11 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> im
//TODO define maps for each difficulty
map = CrimeSceneMap.CrimeSceneMapFactory.createInstance(gfxLibrary, getData().getPositions());
getStage().addActor(map);
contentGroup.addActor(map);
drawWalls(map);
map.addAction(CenterTileAction.getInstance(map.getTile(new Position(0,2))));
getStage().addActor(actionsStripWidget);
contentGroup.addActor(actionsStripWidget);
createStartButton();
generateGameObjects();
......@@ -139,6 +143,10 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> im
@Override
protected void screenResized(int width, int height) {
if(ear != null) {
ear.setSize(getStage().getWidth(), getStage().getHeight());
ear.setPosition(0, getViewportBottomY());
}
}
......@@ -150,10 +158,6 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> im
@Override
protected String getTextKeyForGameResult(GameResult gameResult) {
//TODO make *.properties file with dialog texts
System.out.println("getTextKeyForGameResult " + gameResult.getStarCount() + " " + gameResult.toString());
switch (gameResult) {
case THREE_STAR:
return SCORE3_TEXT_KEY;
......@@ -198,6 +202,13 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> im
}
Music.OnCompletionListener onMusicCompletionListener = new Music.OnCompletionListener() {
@Override
public void onCompletion(Music music) {
gameComplete();
}
};
@Override
protected void gameAct(float delta) {
if (sequenceStarted) {
......@@ -213,16 +224,18 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> im
int selectedActionNumber = actionsStripWidget.getSelectedActions().get(selectedActionPosition).getAction().getActionNumber();
int correctActionNumber = getData().getSolution().get(selectedActionPosition).getActionNumber();
Music music;
if(selectedActionNumber == correctActionNumber) {
getMusic(CrimeSceneObjectType.values()[selectedActionNumber].getSoundPath()).play();
music = getMusic(CrimeSceneObjectType.values()[selectedActionNumber].getSoundPath());
} else {
//TODO play error sound (or correct sound?)
music = getMusic(CrimeSceneObjectType.values()[selectedActionNumber].getSoundPath());
}
if(selectedActionPosition == selectedActions.size() -1) {
gameComplete();
}
if(selectedActionPosition == selectedActions.size() -1) music.setOnCompletionListener(onMusicCompletionListener);
music.play();
selectedActionPosition++;
actionFinished = true;
}
......@@ -275,7 +288,7 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> im
prepareValuesForValidation();
}
});
getStage().addActor(startButton);
contentGroup.addActor(startButton);
startButton.setVisible(false);
}
......@@ -309,17 +322,17 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> im
CrimeSceneObject crimeSceneObject = new CrimeSceneObject(actionsStripWidget, this, crimeObjectType);
crimeSceneObject.setPosition(getAbsolutePositionX(crimeObjectType.getPosition()) + CrimeSceneProperties.TILE_BASE_WIDTH / 2 - crimeSceneObject.getWidth() / 2,
getAbsolutePositionY(crimeObjectType.getPosition()) - crimeSceneObject.getHeight() / 2);
getStage().addActor(crimeSceneObject);
contentGroup.addActor(crimeSceneObject);
return crimeSceneObject;
}
private void drawWalls(CrimeSceneMap map) {
for(Position position : getData().getPositions().keySet()) {
CrimeSceneTile tile = map.getTile(position);
if(tile.getNwWall() != null) getStage().addActor(drawNwWall(position, tile));
if(tile.getNeWall() != null) getStage().addActor(drawNeWall(position, tile));
if(tile.getSeWall() != null) getStage().addActor(drawSeWall(position, tile));
if(tile.getSwWall() != null) getStage().addActor(drawSwWall(position, tile));
if(tile.getNwWall() != null) contentGroup.addActor(drawNwWall(position, tile));
if(tile.getNeWall() != null) contentGroup.addActor(drawNeWall(position, tile));
if(tile.getSeWall() != null) contentGroup.addActor(drawSeWall(position, tile));
if(tile.getSwWall() != null) contentGroup.addActor(drawSwWall(position, tile));
}
}
......@@ -377,14 +390,24 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> im
}
private void playSounds() {
SequenceAction sequence = new SequenceAction(Actions.fadeOut(FADE_OUT_DURATION));
ear = new EarOverlay(getText(CrimeSceneAssets.INSTRUCTIONS_PAY_ATTENTION), ApplicationAtlasManager.getInstance().getColorTexture(Color.BLACK), getScreenTextureRegion(CrimeSceneAssets.EAR));
SequenceAction sequence = new SequenceAction(Actions.alpha(0), Actions.fadeIn(FADE_IN_DURATION));
for(CrimeSceneObjectType objType : getData().getSolution()) {
Music music = getMusic(objType.getSoundPath());
sequence.addAction(new CrimeScenePlayExample(music));
}
sequence.addAction(Actions.fadeIn(FADE_IN_DURATION));
getStage().addAction(sequence);
sequence.addAction(Actions.fadeOut(FADE_OUT_DURATION));
sequence.addAction(Actions.run(new Runnable() {
@Override
public void run() {
ear.remove();
}
}));
ear.setSize(getStage().getWidth(), getStage().getHeight());
ear.setPosition(0, getViewportBottomY());
ear.addAction(sequence);
getStage().addActor(ear);
//TODO dispose music
}
......
......@@ -2,16 +2,9 @@ package cz.nic.tablexia.game.games.crime_scene;
import com.badlogic.gdx.scenes.scene2d.Group;
import java.util.ArrayList;
import java.util.List;
import cz.nic.tablexia.util.ui.actionwidget.Action;
import cz.nic.tablexia.util.ui.actionwidget.ActionsStripWidget;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.delay;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.run;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.sequence;
/**
* Clickable object placed in Crime scene map
*
......@@ -23,9 +16,6 @@ public class CrimeSceneObject extends Group implements Action.ActionListener{
private CrimeSceneGame crimeSceneGame;
private CrimeSceneObjectType crimeSceneObjectType;
//TODO probably could be deleted, its purpose is only to show items one after another
private List<Action> actions = new ArrayList<Action>();
public CrimeSceneObject(ActionsStripWidget actionsStripWidget, CrimeSceneGame crimeSceneGame, CrimeSceneObjectType crimeSceneObjectType) {
this.actionsStripWidget = actionsStripWidget;
this.crimeSceneGame = crimeSceneGame;
......@@ -33,9 +23,7 @@ public class CrimeSceneObject extends Group implements Action.ActionListener{
//TODO change to the objects real size, set X,Y by CrimeSceneObjectType attributes
setSize(CrimeSceneGame.ACTION_SIZE_SMALLER, CrimeSceneGame.ACTION_SIZE_SMALLER);
actions.add(createGameObject(0, true));
showActions();
createGameObject(0, true);
}
private CrimeSceneAction createGameObject(int orderNumber, boolean visible) {
......@@ -44,26 +32,11 @@ public class CrimeSceneObject extends Group implements Action.ActionListener{
action.setActionsStripWidget(actionsStripWidget);
action.setClickable();
addActor(action);
actions.add(action.getOrderNumber(), action);
return action;
}
private void showActions() {
for (int i = 0; i < actions.size(); i++) {
final Action action = actions.get(i);
addAction(sequence(delay(0), run(new Runnable() {
@Override
public void run() {
action.showWithAnimation();
}
})));
}
}
@Override
public void onActionDrag(Action lastAction) {
actions.remove(lastAction);
}
@Override
......
......@@ -5,33 +5,38 @@ package cz.nic.tablexia.game.games.crime_scene.assets;
*/
public class CrimeSceneAssets {
public static final String GFX_PATH = "gfx/";
public static final String COMMON = "common/";
public static final String SFX_PATH = "sfx/";
public static final String GFX_PATH = "gfx/";
public static final String COMMON = "common/";
public static final String SFX_PATH = "sfx/";
public static final String ACTIONS = "actions/";
public static final String TILES = "tiles/";
public static final String CONTROLS_PATH = GFX_PATH + "control/";
public static final String BACKGROUND = GFX_PATH + "background";
public static final String EAR = GFX_PATH + "ear";
public static final String CONTROLS_PATH = GFX_PATH + "control/";
public static final String CONTROL_ACTUAL = CONTROLS_PATH + "actual";
public static final String CONTROL_NEXT = CONTROLS_PATH + "next";
public static final String DOOR_OBJECT = GFX_PATH + "actions/dvere";
public static final String GRAMOPHONE_OBJECT = GFX_PATH + "actions/gram";
public static final String CLOCK_OBJECT = GFX_PATH + "actions/hodiny";
public static final String BOOK_OBJECT = GFX_PATH + "actions/kniha";
public static final String DOOR_OBJECT = GFX_PATH + ACTIONS + "dvere";
public static final String GRAMOPHONE_OBJECT = GFX_PATH + ACTIONS + "gram";
public static final String CLOCK_OBJECT = GFX_PATH + ACTIONS + "hodiny";
public static final String BOOK_OBJECT = GFX_PATH + ACTIONS + "kniha";
public static final String DOOR_ACTION = GFX_PATH + "actions/dvere";
public static final String GRAMOPHONE_ACTION = GFX_PATH + "actions/gram";
public static final String CLOCK_ACTION = GFX_PATH + "actions/hodiny";
public static final String BOOK_ACTION = GFX_PATH + "actions/kniha";
public static final String DOOR_ACTION = GFX_PATH + ACTIONS + "dvere";
public static final String GRAMOPHONE_ACTION = GFX_PATH + ACTIONS + "gram";
public static final String CLOCK_ACTION = GFX_PATH + ACTIONS + "hodiny";
public static final String BOOK_ACTION = GFX_PATH + ACTIONS + "kniha";
public static final String WALL = GFX_PATH + "tiles/wall";
public static final String WALL_DOOR = GFX_PATH + "tiles/wall_door";
public static final String WALL_WINDOW = GFX_PATH + "tiles/wall_window";
public static final String WALL = GFX_PATH + TILES + "wall";
public static final String WALL_DOOR = GFX_PATH + TILES + "wall_door";
public static final String WALL_WINDOW = GFX_PATH + TILES + "wall_window";
public static final String BOOK_SOUND = COMMON + SFX_PATH + "book.mp3";
public static final String CLOCK_SOUND = COMMON + SFX_PATH + "clock.mp3";
public static final String DOOR_SOUND = COMMON + SFX_PATH + "door.mp3";
public static final String GRAMOPHONE_SOUND = COMMON + SFX_PATH + "gramophone.mp3";
public static final String INSTRUCTIONS_PAY_ATTENTION = "game_kidnapping_instructions_pay_attention";
}
......@@ -14,6 +14,7 @@ import cz.nic.tablexia.game.games.kidnapping.media.assets.TextureTypes;
import cz.nic.tablexia.game.games.kidnapping.model.Direction;
import cz.nic.tablexia.game.games.kidnapping.model.GameState;
import cz.nic.tablexia.util.ui.EarOverlay;
import cz.nic.tablexia.util.ui.tilemapgenerator.*;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.util.ScaleUtil;
......
package cz.nic.tablexia.game.games.kidnapping.actors;
package cz.nic.tablexia.util.ui;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
......@@ -8,15 +8,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.util.ui.TablexiaLabel;
/**
* Created by lhoracek on 5/19/15.
*/
public class EarOverlay extends Group {
private static final ApplicationFontManager.FontType_NEW FONT_TYPE = ApplicationFontManager.FontType_NEW.REGULAR_30;
private static final Color FONT_COLOR = Color.WHITE;
private static final Color FONT_COLOR = Color.WHITE;
private Image ear, overlay;
private TablexiaLabel text;
......
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