Skip to content
Snippets Groups Projects
Commit 5c7202a8 authored by Drahomír Karchňák's avatar Drahomír Karchňák
Browse files

#57 - Added additional help screen

parent 08a293c4
No related branches found
No related tags found
No related merge requests found
package cz.nic.tablexia.game.games.kidnapping;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.EventListener;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
......@@ -16,7 +20,6 @@ import java.util.List;
import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.common.media.AssetDescription;
import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.common.media.SfxLibrary;
......@@ -39,10 +42,14 @@ import cz.nic.tablexia.game.games.kidnapping.model.Direction;
import cz.nic.tablexia.game.games.kidnapping.model.GameState;
import cz.nic.tablexia.game.games.kidnapping.model.Position;
import cz.nic.tablexia.game.games.kidnapping.util.DirectionsHelper;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.model.game.Game;
import cz.nic.tablexia.util.ScaleUtil;
import cz.nic.tablexia.util.ui.AnimatedImage;
import cz.nic.tablexia.util.ui.ClickListenerWithSound;
import cz.nic.tablexia.util.ui.TablexiaButton;
/**
* Created by lhoracek on 6.3.15.
......@@ -53,7 +60,10 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
private SfxLibrary sfxLibrary = new SfxLibrary(this, SoundType.values());
private Map map;
@Override
private boolean helpShown = false;
private ApplicationFontManager.FontType HELP_OVERLAY_FONT = ApplicationFontManager.FontType.ROBOTO_BOLD_20;
@Override
protected void prepareGameSoundAssetNames(List<String> soundsFileNames) {
soundsFileNames.addAll(sfxLibrary.values());
}
......@@ -69,6 +79,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
// TODO show sub-rule screen
getStage().addActor(map = Map.MapFactory.createInstance(this, gfxLibrary, getData()));
map.setMapScale(0.5f);
// center first tile and start game
map.addAction(CenterTileAction.getInstance(map.getTile(getData().getCurrentPosition())));
map.getReplayButton().addListener(new ClickListener() {
......@@ -77,19 +88,72 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
getData().addReplay();
}
});
map.addAction(Actions.alpha(0f));
map.addAction(Actions.visible(false));
screenResized(0, 0);
}
public void showHelpOverlay() {
final Group group = new Group();
Image background = new Image(getApplicationTextureRegion(ApplicationAtlasManager.BACKGROUND_WOODEN));
setActorToFullScene(background);
group.addActor(background);
//TODO FINISH IT
Image image = new Image(gfxLibrary.getTextureRegion(TextureTypes.PAPER));
image.setSize(getSceneWidth() * 0.6f, getSceneInnerHeight());
image.setPosition(getSceneLeftX() + getSceneWidth() / 2 - image.getWidth() / 2, getSceneInnerBottomY());
group.addActor(image);
TablexiaButton button = new TablexiaButton("Rozumim", TablexiaButton.ButtonType.GREEN);
button.setPosition(getSceneLeftX() + getSceneWidth() / 2 - button.getWidth() / 2, getSceneInnerBottomY() + getSceneInnerHeight() * .2f);
button.addListener(new ClickListenerWithSound() {
@Override
public void onClick(InputEvent event, float x, float y) {
super.onClick(event, x, y);
group.addAction(new SequenceAction(Actions.fadeOut(0.5f), Actions.visible(false)));
map.addAction(Actions.sequence(Actions.delay(1),
Actions.run(new Runnable() {
public void run() {
startRound();
}
})));
}
});
group.addActor(button);
BitmapFont helpLabelFont = ApplicationFontManager.getInstance().getFont(HELP_OVERLAY_FONT);
Label helpOverlayText = new Label("Lorem Ipsum ", new Label.LabelStyle(helpLabelFont, Color.BLACK));
helpOverlayText.setPosition(getSceneLeftX() + getSceneWidth() / 2 - helpOverlayText.getWidth() / 2,
getSceneInnerBottomY() + getSceneInnerHeight() / 2 - helpOverlayText.getHeight() / 2);
group.addActor(helpOverlayText);
getStage().addActor(group);
}
@Override
protected void gameVisible() {
// center first tile and start game
map.addAction(Actions.sequence(Actions.delay(2),
Actions.run(new Runnable() {
public void run() {
startRound();
}
})));
}
// center first tile and start game
if(!helpShown) {
showHelpOverlay();
}
else {
map.addAction(Actions.sequence(Actions.delay(1),
Actions.run(new Runnable() {
public void run() {
startRound();
}
})));
}
}
@Override
protected void screenResized(int width, int height) {
......@@ -102,9 +166,16 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
* Plays example sound and all sounds for directions, then shows the replay button
*/
private void startRound() {
map.addAction(Actions.sequence(ReplayAlphaAction.fadeOut(), Actions.parallel(CenterTileAction.getInstance(map.getTile(getData().getCurrentPosition()), 0.7f), getData().getStep() != 0 ? ShowRoadAction.fadeIn(getData().getLastPosition(), getData().getLastDirectionFrom().getOppositeDirection()) : Actions.delay(0)), ShowFlagAction.fadeIn(getData().getCurrentPosition()), Actions.delay(0.5f), Actions.run(new Runnable() {
map.addAction( Actions.sequence( Actions.visible(true),
Actions.fadeIn(0.5f),
ReplayAlphaAction.fadeOut(),
Actions.parallel( CenterTileAction.getInstance(map.getTile(getData().getCurrentPosition()), 0.7f),
getData().getStep() != 0 ? ShowRoadAction.fadeIn(getData().getLastPosition(), getData().getLastDirectionFrom().getOppositeDirection()) : Actions.delay(0)),
ShowFlagAction.fadeIn(getData().getCurrentPosition()),
Actions.delay(0.5f),
Actions.run(new Runnable() {
public void run() {
playSounds();
playSounds();
}
})));
}
......
......@@ -31,6 +31,7 @@ public enum TextureTypes implements AssetDescription {
POSITION_CURRENT("zde-jsi"), //
OVERLAY("overlay"), //
EAR("ear"), //
PAPER("papir-pravidla"),
POSITION_LINE_NWSE("lineNWSE-2"), //
POSITION_LINE_NESW("lineNESW-2"), //
......
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