Commit a1198376 authored by Matyáš Latner's avatar Matyáš Latner

#83 Zvvýraznění kroků v tutoriálu

parent 0723a198
obb/potme/gfx/info/start_arrow.png

37.3 KB | W: | H:

obb/potme/gfx/info/start_arrow.png

36.5 KB | W: | H:

obb/potme/gfx/info/start_arrow.png
obb/potme/gfx/info/start_arrow.png
obb/potme/gfx/info/start_arrow.png
obb/potme/gfx/info/start_arrow.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -21,6 +21,7 @@ package cz.nic.tablexia.game.games.potme; ...@@ -21,6 +21,7 @@ package cz.nic.tablexia.game.games.potme;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -83,7 +84,7 @@ import cz.nic.tablexia.game.manager.GameManager; ...@@ -83,7 +84,7 @@ import cz.nic.tablexia.game.manager.GameManager;
*/ */
public class PotmeActivity extends GameActivity implements TileMapClickListener { public class PotmeActivity extends GameActivity implements TileMapClickListener {
public enum GameLayer { public static enum GameLayer {
BACKGROUND_TEXTURE_LAYER (0), BACKGROUND_TEXTURE_LAYER (0),
BACKGROUND_DRAWING_LAYER (1), BACKGROUND_DRAWING_LAYER (1),
BUTTON_LAYER (2), BUTTON_LAYER (2),
...@@ -138,6 +139,11 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -138,6 +139,11 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
scene.sortChildren(); scene.sortChildren();
} }
} }
public static final List<ActionType> TUTORIAL_STEPS = Arrays.asList(new ActionType[]{ActionType.GO,
ActionType.RIGHT,
ActionType.DOOR,
ActionType.GO});
private static final boolean SHOW_DEBUGINFO_RULE = true; private static final boolean SHOW_DEBUGINFO_RULE = true;
...@@ -167,8 +173,6 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -167,8 +173,6 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private static final int GAME_INFO_FINISH_ALPHA = 1; private static final int GAME_INFO_FINISH_ALPHA = 1;
private static final int GAME_INFO_START_ALPHA = 0; private static final int GAME_INFO_START_ALPHA = 0;
private static final float GAME_INFO_APPEAR_DURATION = 0.3f; private static final float GAME_INFO_APPEAR_DURATION = 0.3f;
private static final float GAME_INFO_ARROW_APPEAR_DURATION = 1f;
private static final int GAME_INFO_ARROW_APPEAR_DELAY = 2;
public static int TILE_SIZE; public static int TILE_SIZE;
public static int MAP_START_POSITION_X; public static int MAP_START_POSITION_X;
...@@ -259,13 +263,13 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -259,13 +263,13 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
textPressedPositionY = unpressedButtonSprite.getHeight() / 8; textPressedPositionY = unpressedButtonSprite.getHeight() / 8;
buttonText = new Text(textUnpressedPositionX, textUnpressedPositionY, ResourceManager.getInstance().getFont(), getString(R.string.game_potme_start), getVertexBufferObjectManager()); buttonText = new Text(textUnpressedPositionX, textUnpressedPositionY, ResourceManager.getInstance().getFont(), getString(R.string.game_potme_start), getVertexBufferObjectManager());
textLayer.attachChild(buttonText); textLayer.attachChild(buttonText);
disable();
} }
public void enable() { public void enable() {
enabled = true; enabled = true;
changeActualButtonSprite(unpressedButtonSprite); changeActualButtonSprite(unpressedButtonSprite);
buttonText.setPosition(textUnpressedPositionX, textUnpressedPositionY); buttonText.setPosition(textUnpressedPositionX, textUnpressedPositionY);
hideStartArrowInfo();
} }
public void disable() { public void disable() {
...@@ -386,8 +390,11 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -386,8 +390,11 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
actionsStripWidget = showActionsStripWidget(actionStripWidgetWidth); actionsStripWidget = showActionsStripWidget(actionStripWidgetWidth);
actionsWidget = showActionsWidget(getPotmeDifficulty(), actionStripWidgetWidth); actionsWidget = showActionsWidget(getPotmeDifficulty(), actionStripWidgetWidth);
startButton = showStartButton((int)actionsWidget.getX()); startButton = showStartButton((int)actionsWidget.getX());
//TODO remove and use event bus //TODO remove and use event bus
actionsStripWidget.setStartButton(startButton); actionsStripWidget.setStartButton(startButton);
actionsWidget.setStartButton(startButton);
player = showPlayer(); player = showPlayer();
prepareGameInfos(actionStripWidgetWidth); prepareGameInfos(actionStripWidgetWidth);
...@@ -405,7 +412,6 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -405,7 +412,6 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
goToPlanningMode(); goToPlanningMode();
super.showGame(); super.showGame();
actionsWidget.showActions(); actionsWidget.showActions();
showStartArrowInfo();
} }
/* //////////////////////////////////////////// BACKGROUND */ /* //////////////////////////////////////////// BACKGROUND */
...@@ -537,12 +543,14 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -537,12 +543,14 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
Sprite actionStripBackground = new Sprite(displaySize.x - (actionStripWidgetWidth / 2), displaySize.y - (displaySize.y / 2), actionStripWidgetWidth, displaySize.y, ResourceManager.getInstance().getTexture(ResourceManager.BACKGROUND_ACTIONSTRIP_TEXTURE), getVertexBufferObjectManager()); Sprite actionStripBackground = new Sprite(displaySize.x - (actionStripWidgetWidth / 2), displaySize.y - (displaySize.y / 2), actionStripWidgetWidth, displaySize.y, ResourceManager.getInstance().getTexture(ResourceManager.BACKGROUND_ACTIONSTRIP_TEXTURE), getVertexBufferObjectManager());
GameLayer.BACKGROUND_TEXTURE_LAYER.getLayerEntity().attachChild(actionStripBackground); GameLayer.BACKGROUND_TEXTURE_LAYER.getLayerEntity().attachChild(actionStripBackground);
ActionsStripWidget actionStripWidget = new ActionsStripWidget(displaySize.x, displaySize.y, actionStripWidgetWidth, displaySize.y, scene, getVertexBufferObjectManager()); ActionsStripWidget actionStripWidget = new ActionsStripWidget(displaySize.x, displaySize.y, actionStripWidgetWidth, displaySize.y, scene, getVertexBufferObjectManager());
actionStripWidget.enableActionSorting(getPotmeDifficulty() != PotmeDifficulty.TUTORIAL);
actionStripWidget.enableStartButtonControl(getPotmeDifficulty() != PotmeDifficulty.TUTORIAL);
GameLayer.ACTION_STRIP_LAYER.getLayerEntity().attachChild(actionStripWidget); GameLayer.ACTION_STRIP_LAYER.getLayerEntity().attachChild(actionStripWidget);
return actionStripWidget; return actionStripWidget;
} }
private ActionsWidget showActionsWidget(PotmeDifficulty potmeDifficulty, int actionStripWidgetWidth) { private ActionsWidget showActionsWidget(PotmeDifficulty potmeDifficulty, int actionStripWidgetWidth) {
ActionsWidget widget = new ActionsWidget(displaySize.x - actionStripWidgetWidth - (2 * ACTION_SIZE_SMALLER), displaySize.y - ACTION_SIZE_SMALLER, potmeDifficulty, scene, actionsStripWidget, getVertexBufferObjectManager()); ActionsWidget widget = new ActionsWidget(displaySize.x - actionStripWidgetWidth - (2 * ACTION_SIZE_SMALLER), displaySize.y - ACTION_SIZE_SMALLER, displaySize.x, displaySize.y, potmeDifficulty, scene, actionsStripWidget, actionStripWidgetWidth, getVertexBufferObjectManager());
GameLayer.ACTIONS_LAYER.getLayerEntity().attachChild(widget); GameLayer.ACTIONS_LAYER.getLayerEntity().attachChild(widget);
return widget; return widget;
...@@ -789,27 +797,6 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -789,27 +797,6 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
createInfoSprite(GameLayer.INFO_LAYER, ResourceManager.INFO_CRASH, gameInfoPositionX, gameInfoPositionY, gameInfoWidth, gameInfoHeight); createInfoSprite(GameLayer.INFO_LAYER, ResourceManager.INFO_CRASH, gameInfoPositionX, gameInfoPositionY, gameInfoWidth, gameInfoHeight);
createInfoSprite(GameLayer.INFO_LAYER, ResourceManager.INFO_SAFE1, gameInfoPositionX, gameInfoPositionY, gameInfoWidth, gameInfoHeight); createInfoSprite(GameLayer.INFO_LAYER, ResourceManager.INFO_SAFE1, gameInfoPositionX, gameInfoPositionY, gameInfoWidth, gameInfoHeight);
createInfoSprite(GameLayer.INFO_LAYER, ResourceManager.INFO_SAFE2, gameInfoPositionX, gameInfoPositionY, gameInfoWidth, gameInfoHeight); createInfoSprite(GameLayer.INFO_LAYER, ResourceManager.INFO_SAFE2, gameInfoPositionX, gameInfoPositionY, gameInfoWidth, gameInfoHeight);
float startArrowWidth = TILE_SIZE * 1.5f;
float startArrowHeight = TILE_SIZE * 1.5f;
float startPositionX = displaySize.x - actionStripWidgetWidth - ACTION_SIZE_SMALLER + (startArrowWidth * 2/3);
float startPositionY = MAP_START_POSITION_Y - mapWidgets.get(0).getHeight() + startArrowHeight;
createInfoSprite(GameLayer.BACKGROUND_DRAWING_LAYER, ResourceManager.INFO_START_ARROW, startPositionX, startPositionY, startArrowWidth, startArrowHeight);
}
private void showStartArrowInfo() {
scene.registerEntityModifier(new DelayModifier(GAME_INFO_ARROW_APPEAR_DELAY) {
@Override
protected void onModifierFinished(IEntity pItem) {
showGameInfo(ResourceManager.INFO_START_ARROW, true, GAME_INFO_ARROW_APPEAR_DURATION, null);
}
});
}
private void hideStartArrowInfo() {
hideGameInfo(ResourceManager.INFO_START_ARROW, true, null);
} }
public void showCrashInfo() { public void showCrashInfo() {
......
...@@ -167,13 +167,16 @@ public class Action extends Sprite { ...@@ -167,13 +167,16 @@ public class Action extends Sprite {
/* //////////////////////////////////////////// ACTION STATE */ /* //////////////////////////////////////////// ACTION STATE */
public void setEnbaled(boolean enabled) {
clickable = enabled;
}
public void disable() { public void disable() {
clickable = false; setEnbaled(false);
} }
public void enable() { public void enable() {
clickable = true; setEnbaled(true);
} }
......
...@@ -38,9 +38,9 @@ import org.andengine.util.modifier.ease.EaseBackOut; ...@@ -38,9 +38,9 @@ import org.andengine.util.modifier.ease.EaseBackOut;
import org.andengine.util.modifier.ease.EaseLinear; import org.andengine.util.modifier.ease.EaseLinear;
import cz.nic.tablexia.game.games.potme.PotmeActivity; import cz.nic.tablexia.game.games.potme.PotmeActivity;
import cz.nic.tablexia.game.games.potme.PotmeActivity.StartButton;
import cz.nic.tablexia.game.games.potme.ResourceManager; import cz.nic.tablexia.game.games.potme.ResourceManager;
import cz.nic.tablexia.game.games.potme.UtilityAccess; import cz.nic.tablexia.game.games.potme.UtilityAccess;
import cz.nic.tablexia.game.games.potme.PotmeActivity.StartButton;
import cz.nic.tablexia.game.games.potme.action.Action; import cz.nic.tablexia.game.games.potme.action.Action;
import cz.nic.tablexia.game.games.potme.action.Action.ActionListener; import cz.nic.tablexia.game.games.potme.action.Action.ActionListener;
import cz.nic.tablexia.game.games.potme.action.ActionContainer; import cz.nic.tablexia.game.games.potme.action.ActionContainer;
...@@ -79,6 +79,8 @@ public class ActionsStripWidget extends Entity implements ActionListener { ...@@ -79,6 +79,8 @@ public class ActionsStripWidget extends Entity implements ActionListener {
private MoveModifier nextActionFieldMoveModifier; private MoveModifier nextActionFieldMoveModifier;
private MoveModifier scrollPaneMoveModifier; private MoveModifier scrollPaneMoveModifier;
private int actionOffsetX; private int actionOffsetX;
private boolean startButtonControl;
private boolean enableActionSorting;
public ActionsStripWidget(int positionX, public ActionsStripWidget(int positionX,
int positionY, int positionY,
...@@ -95,6 +97,9 @@ public class ActionsStripWidget extends Entity implements ActionListener { ...@@ -95,6 +97,9 @@ public class ActionsStripWidget extends Entity implements ActionListener {
this.vertexBufferObjectManager = vertexBufferObjectManager; this.vertexBufferObjectManager = vertexBufferObjectManager;
this.actionOffsetX = width / 8; this.actionOffsetX = width / 8;
enableActionSorting = true;
startButtonControl = true;
actualSelectedActionPosition = NO_SELECTED_POSITION; actualSelectedActionPosition = NO_SELECTED_POSITION;
selectedActions = new ArrayList<ActionContainer>(); selectedActions = new ArrayList<ActionContainer>();
...@@ -130,6 +135,14 @@ public class ActionsStripWidget extends Entity implements ActionListener { ...@@ -130,6 +135,14 @@ public class ActionsStripWidget extends Entity implements ActionListener {
return selectedActions.size() < MAXIMUM_ACTIONS_COUNT; return selectedActions.size() < MAXIMUM_ACTIONS_COUNT;
} }
public void enableStartButtonControl(boolean startButtonControl) {
this.startButtonControl = startButtonControl;
}
public void enableActionSorting(boolean enableActionSorting) {
this.enableActionSorting = enableActionSorting;
}
/* //////////////////////////////////////////// BACKGROUND AND SCROLLING */ /* //////////////////////////////////////////// BACKGROUND AND SCROLLING */
...@@ -382,7 +395,7 @@ public class ActionsStripWidget extends Entity implements ActionListener { ...@@ -382,7 +395,7 @@ public class ActionsStripWidget extends Entity implements ActionListener {
} }
public void performCollisionWithNumberStart(int collisionNumber) { public void performCollisionWithNumberStart(int collisionNumber) {
if (isNotFull()) { if (isNotFull() && enableActionSorting) {
if (collisionNumber > 0 && collisionNumber < selectedActions.size()) { if (collisionNumber > 0 && collisionNumber < selectedActions.size()) {
moveNextActionTemporalyHalfUp(); moveNextActionTemporalyHalfUp();
moveActionsFromPositionHalfDown(collisionNumber); moveActionsFromPositionHalfDown(collisionNumber);
...@@ -421,10 +434,12 @@ public class ActionsStripWidget extends Entity implements ActionListener { ...@@ -421,10 +434,12 @@ public class ActionsStripWidget extends Entity implements ActionListener {
} }
public void setStartButtonState() { public void setStartButtonState() {
if (selectedActions.size() > 0) { if (startButtonControl) {
enableStartButton(); if (selectedActions.size() > 0) {
} else { enableStartButton();
disableStartButton(); } else {
disableStartButton();
}
} }
} }
...@@ -458,7 +473,8 @@ public class ActionsStripWidget extends Entity implements ActionListener { ...@@ -458,7 +473,8 @@ public class ActionsStripWidget extends Entity implements ActionListener {
// add new action // add new action
ActionContainer actionContainer = createActionContainer(createAction(selectedActionType, selectedActionPosition)); ActionContainer actionContainer = createActionContainer(createAction(selectedActionType, selectedActionPosition));
if (selectedActionPosition > selectedActions.size()) { actionContainer.getAction().setEnbaled(enableActionSorting);
if (selectedActionPosition > selectedActions.size() || !enableActionSorting) {
selectedActions.add(actionContainer); selectedActions.add(actionContainer);
} else { } else {
selectedActions.add(selectedActionPosition, actionContainer); selectedActions.add(selectedActionPosition, actionContainer);
......
...@@ -23,13 +23,17 @@ import java.util.ArrayList; ...@@ -23,13 +23,17 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.andengine.entity.Entity; import org.andengine.entity.Entity;
import org.andengine.entity.IEntity;
import org.andengine.entity.primitive.Rectangle;
import org.andengine.entity.scene.Scene; import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite; import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.region.ITextureRegion; import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager; import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.adt.color.Color;
import android.os.Handler; import android.os.Handler;
import cz.nic.tablexia.game.games.potme.PotmeActivity; import cz.nic.tablexia.game.games.potme.PotmeActivity;
import cz.nic.tablexia.game.games.potme.PotmeActivity.StartButton;
import cz.nic.tablexia.game.games.potme.PotmeDifficulty; import cz.nic.tablexia.game.games.potme.PotmeDifficulty;
import cz.nic.tablexia.game.games.potme.ResourceManager; import cz.nic.tablexia.game.games.potme.ResourceManager;
import cz.nic.tablexia.game.games.potme.action.Action; import cz.nic.tablexia.game.games.potme.action.Action;
...@@ -43,28 +47,85 @@ import cz.nic.tablexia.game.games.potme.action.ActionType; ...@@ -43,28 +47,85 @@ import cz.nic.tablexia.game.games.potme.action.ActionType;
* *
*/ */
public class ActionsWidget extends Entity implements ActionListener { public class ActionsWidget extends Entity implements ActionListener {
public enum ActionLayer {
BACKGROUND_LAYER (0),
ACTIONS_LAYER (1),
INFO_LAYER (2);
private Entity layerEntity;
private int layerZIndex;
private ActionLayer(int layerZIndex) {
this.layerZIndex = layerZIndex;
}
private void setLayerEntity(Entity layerEntity) {
this.layerEntity = layerEntity;
}
public Entity getLayerEntity() {
return layerEntity;
}
public int getLayerZIndex() {
return layerZIndex;
}
public static void attachLayersToEntity(IEntity conteinerEntity) {
for (ActionLayer actionLayer : ActionLayer.values()) {
Entity entity = new Entity();
actionLayer.setLayerEntity(entity);
conteinerEntity.attachChild(entity);
entity.setZIndex(actionLayer.getLayerZIndex());
}
conteinerEntity.sortChildren();
}
}
private static final int TOP_Z_INDEX = ActionType.values().length + 1;
private static final float BACKGROUND_WIDTH_RATIO = 1.3f; private static final float BACKGROUND_WIDTH_RATIO = 1.3f;
private static final double BACKGROUND_Y_POSITION_RATIO = 0.9; private static final double BACKGROUND_Y_POSITION_RATIO = 0.9;
private static final int START_ANIMATION_DELAY = 200; private static final int START_ANIMATION_DELAY = 200;
private static final int NUMBER_OF_COLUMNS = 2; private static final int NUMBER_OF_COLUMNS = 2;
public static final int ACTION_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER / 10; public static final int ACTION_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER / 10;
private static final float DIMMER_ALPHA = 0.5f;
private static final Color DIMMER_COLOR = Color.BLACK;
private static final float START_ARROW_WIDTH = PotmeActivity.TILE_SIZE * 1.2f;
private static final float START_ARROW_HEIGHT = PotmeActivity.TILE_SIZE;
private ActionsStripWidget actionsStripWidget; private ActionsStripWidget actionsStripWidget;
private List<Action> actions; private List<Action> actions;
private VertexBufferObjectManager vertexBufferObjectManager; private VertexBufferObjectManager vertexBufferObjectManager;
private final Scene scene; private final Scene scene;
private Rectangle dimmer;
private PotmeDifficulty potmeDifficulty;
private int currentStepNumber;
private StartButton startButton;
public ActionsWidget(float positionX, float positionY, PotmeDifficulty potmeDifficulty, Scene scene, ActionsStripWidget actionsStripWidget, VertexBufferObjectManager vertexBufferObjectManager) { public ActionsWidget(float positionX,
float positionY,
float displaySizeX,
float displaySizeY,
PotmeDifficulty potmeDifficulty,
Scene scene,
ActionsStripWidget actionsStripWidget,
float actionStripWidgetWidth,
VertexBufferObjectManager vertexBufferObjectManager) {
super(positionX, positionY); super(positionX, positionY);
this.potmeDifficulty = potmeDifficulty;
this.scene = scene; this.scene = scene;
this.actionsStripWidget = actionsStripWidget; this.actionsStripWidget = actionsStripWidget;
this.vertexBufferObjectManager = vertexBufferObjectManager; this.vertexBufferObjectManager = vertexBufferObjectManager;
this.actions = new ArrayList<Action>(); this.actions = new ArrayList<Action>();
currentStepNumber = 0;
List<ActionType> actionTypes = ActionType.getActionTypesForGameDifficulty(potmeDifficulty); List<ActionType> actionTypes = ActionType.getActionTypesForGameDifficulty(potmeDifficulty);
// BACKGROUND
ITextureRegion backgroundTexture = ResourceManager.getInstance().getTexture(ResourceManager.BACKGROUND_ACTIONS_TEXTURE); ITextureRegion backgroundTexture = ResourceManager.getInstance().getTexture(ResourceManager.BACKGROUND_ACTIONS_TEXTURE);
int backgroundWidth = (int)((NUMBER_OF_COLUMNS * PotmeActivity.ACTION_SIZE_SMALLER) * BACKGROUND_WIDTH_RATIO); int backgroundWidth = (int)((NUMBER_OF_COLUMNS * PotmeActivity.ACTION_SIZE_SMALLER) * BACKGROUND_WIDTH_RATIO);
int backgroundHeight = (int)(backgroundWidth * (backgroundTexture.getHeight() / backgroundTexture.getWidth())); int backgroundHeight = (int)(backgroundWidth * (backgroundTexture.getHeight() / backgroundTexture.getWidth()));
...@@ -73,11 +134,31 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -73,11 +134,31 @@ public class ActionsWidget extends Entity implements ActionListener {
backgroundWidth, backgroundWidth,
backgroundHeight, backgroundHeight,
backgroundTexture, vertexBufferObjectManager); backgroundTexture, vertexBufferObjectManager);
attachChild(actionsBackground);
for (int i = 0; i < actionTypes.size(); i++) {
createAction(actionTypes.get(i), i, false, scene); // DIMMER
float actionStripWidgetOffset = (actionStripWidgetWidth / 2) * 0.95f;
dimmer = new Rectangle(-positionX + (displaySizeX / 2) - actionStripWidgetOffset,
-positionY + (displaySizeY / 2),
displaySizeX - actionStripWidgetOffset,
displaySizeY,
vertexBufferObjectManager);
dimmer.setColor(DIMMER_COLOR);
dimmer.setAlpha(DIMMER_ALPHA);
dimmer.setVisible(false);
ActionLayer.attachLayersToEntity(this);
for (ActionType actionType : actionTypes) {
createAction(actionType, actionType.ordinal(), false, scene);
} }
ActionLayer.ACTIONS_LAYER.getLayerEntity().attachChild(dimmer);
ActionLayer.BACKGROUND_LAYER.getLayerEntity().attachChild(actionsBackground);
tryToPerformNextTutorialStep();
}
public void setStartButton(StartButton startButton) {
this.startButton = startButton;
} }
private Action createAction(ActionType actionType, int orderNumber, boolean visible, Scene scene) { private Action createAction(ActionType actionType, int orderNumber, boolean visible, Scene scene) {
...@@ -91,11 +172,12 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -91,11 +172,12 @@ public class ActionsWidget extends Entity implements ActionListener {
action.addActionListener(this); action.addActionListener(this);
action.setClickable(scene); action.setClickable(scene);
attachChild(action); ActionLayer.ACTIONS_LAYER.getLayerEntity().attachChild(action);
actions.add(action); actions.add(action.getOrderNumber(), action);
return action; return action;
} }
/* //////////////////////////////////////////// COLLISIONS */ /* //////////////////////////////////////////// COLLISIONS */
private void prepareActionsCollisionEntity(Action action) { private void prepareActionsCollisionEntity(Action action) {
...@@ -125,8 +207,10 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -125,8 +207,10 @@ public class ActionsWidget extends Entity implements ActionListener {
/* //////////////////////////////////////////// ACTION STATE */ /* //////////////////////////////////////////// ACTION STATE */
public void enableActions() { public void enableActions() {
for (Action action : actions) { if (potmeDifficulty != PotmeDifficulty.TUTORIAL) {
action.enable(); for (Action action : actions) {
action.enable();
}
} }
} }
...@@ -147,14 +231,73 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -147,14 +231,73 @@ public class ActionsWidget extends Entity implements ActionListener {
action.showWithAnimation(); action.showWithAnimation();
prepareActionsCollisionEntity(action); prepareActionsCollisionEntity(action);
disableActions(); disableActions();
hideArrowSprite();
} }
@Override @Override
public void onActionDrop(Action action, int collidesWithNumber) { public void onActionDrop(Action action, int collidesWithNumber) {
PotmeActivity.GameLayer.resetLayersZIndexes(scene); PotmeActivity.GameLayer.resetLayersZIndexes(scene);
enableActions();
if (collidesWithNumber != Action.NO_COLLISION_NUMBER) { if (collidesWithNumber != Action.NO_COLLISION_NUMBER) {
actionsStripWidget.addSelectedAction(action.getActionType(), collidesWithNumber); actionsStripWidget.addSelectedAction(action.getActionType(), collidesWithNumber);
currentStepNumber++;
} }
tryToPerformNextTutorialStep();
}
/* //////////////////////////////////////////// TUTORIAL STEPS */
private void tryToPerformNextTutorialStep() {
if (potmeDifficulty == PotmeDifficulty.TUTORIAL) {
if (currentStepNumber < PotmeActivity.TUTORIAL_STEPS.size()) {
highliteAction(PotmeActivity.TUTORIAL_STEPS.get(currentStepNumber));
if (startButton != null) {
startButton.disable();
}
} else {
PotmeActivity.GameLayer.BUTTON_LAYER.sendToFront(scene);
if (startButton != null) {
startButton.enable();
}
}
} else {
enableActions();
}
}
private void dimmAllActions() {
dimmer.setVisible(true);
for (Action action : actions) {
action.setZIndex(action.getOrderNumber());
action.disable();
}
dimmer.setZIndex(actions.size());
ActionLayer.ACTIONS_LAYER.getLayerEntity().sortChildren();
}
private void highliteAction(ActionType actionType) {
if (actionType.ordinal() < actions.size()) {
dimmAllActions();
Action action = actions.get(actionType.ordinal());
action.setZIndex(TOP_Z_INDEX);
action.enable();
showArrowSprite(action.getX(), action.getY(), vertexBufferObjectManager);
ActionLayer.ACTIONS_LAYER.getLayerEntity().sortChildren();
}
}
private void showArrowSprite(float positionX, float positionY, VertexBufferObjectManager vertexBufferObjectManager) {
hideArrowSprite();
Sprite infoArrowSprite = new Sprite(positionX + (PotmeActivity.ACTION_SIZE_SMALLER * 1.2f),
positionY - (PotmeActivity.ACTION_SIZE_SMALLER / 2),
START_ARROW_WIDTH,
START_ARROW_HEIGHT,
ResourceManager.getInstance().getTexture(ResourceManager.INFO_START_ARROW),
vertexBufferObjectManager);
ActionLayer.INFO_LAYER.getLayerEntity().attachChild(infoArrowSprite);
}
private void hideArrowSprite() {
ActionLayer.INFO_LAYER.getLayerEntity().detachChildren();
} }
} }
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