Commit 93bd63dc authored by Luboš Horáček's avatar Luboš Horáček

Merge branch 'feature-potme' into 'devel'

Feature potme

See merge request !42
parents 61fb9c49 e00054ef
obb/potme/gfx/control/actual.png

3.55 KB | W: | H:

obb/potme/gfx/control/actual.png

2.94 KB | W: | H:

obb/potme/gfx/control/actual.png
obb/potme/gfx/control/actual.png
obb/potme/gfx/control/actual.png
obb/potme/gfx/control/actual.png
  • 2-up
  • Swipe
  • Onion skin
obb/potme/gfx/objects/safe.png

3 KB | W: | H:

obb/potme/gfx/objects/safe.png

3.25 KB | W: | H:

obb/potme/gfx/objects/safe.png
obb/potme/gfx/objects/safe.png
obb/potme/gfx/objects/safe.png
obb/potme/gfx/objects/safe.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -166,6 +166,8 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private static final int GAME_INFO_FINISH_ALPHA = 1;
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_ARROW_APPEAR_DURATION = 1f;
private static final int GAME_INFO_ARROW_APPEAR_DELAY = 2;
public static int TILE_SIZE;
public static int MAP_START_POSITION_X;
......@@ -259,6 +261,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
enabled = true;
changeActualButtonSprite(unpressedButtonSprite);
buttonText.setPosition(textUnpressedPositionX, textUnpressedPositionY);
hideStartArrowInfo();
}
public void disable() {
......@@ -378,7 +381,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
actionsStripWidget.setStartButton(startButton);
player = showPlayer();
prepareGameInfos();
prepareGameInfos(actionStripWidgetWidth);
prepareFadeLayer();
prepareKeyIcon();
......@@ -393,6 +396,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
goToPlanningMode();
super.showGame();
actionsWidget.showActions();
showStartArrowInfo();
}
/* //////////////////////////////////////////// BACKGROUND */
......@@ -501,7 +505,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
finishMapObjetcMapObjectType = MapObjectType.STAIRS;
}
boolean floorHasKey = hasKey && ((floorCount - 1) / 2) == i;
MapWidget mapWidget = new MapWidget(lastFinishPosition, finishMapObjetcMapObjectType, i, MAP_START_POSITION_X, MAP_START_POSITION_Y, MAP_X_SIZE, MAP_Y_SIZE, floorHasKey, randomAccess, getResources().getText(R.string.game_potme_floor).toString(), getVertexBufferObjectManager());
MapWidget mapWidget = new MapWidget(lastFinishPosition, finishMapObjetcMapObjectType, i, floorCount > 1, MAP_START_POSITION_X, MAP_START_POSITION_Y, MAP_X_SIZE, MAP_Y_SIZE, floorHasKey, randomAccess, getResources().getText(R.string.game_potme_floor).toString(), getVertexBufferObjectManager());
mapWidgets.add(mapWidget);
if (i == 0) {
......@@ -762,36 +766,92 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private Map<String, Sprite> gameInfos;
private void prepareGameInfos() {
private void prepareGameInfos(int actionStripWidgetWidth) {
gameInfos = new HashMap<String, Sprite>();
createCrashInfoSprite(ResourceManager.INFO_CRASH);
createCrashInfoSprite(ResourceManager.INFO_SAFE1);
createCrashInfoSprite(ResourceManager.INFO_SAFE2);
float gameInfoPositionX = MAP_START_POSITION_X + (mapWidgets.get(0).getWidth() / 2);
float gameInfoPositionY = MAP_START_POSITION_Y - (mapWidgets.get(0).getHeight() / 2);
float gameInfoWidth = TILE_SIZE * GAME_INFO_TILE_SIZE_MULTIPLIER;
float gameInfoHeight = TILE_SIZE * GAME_INFO_TILE_SIZE_MULTIPLIER;
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_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() {
showGameInfo(ResourceManager.INFO_CRASH, true, null);
showGameInfo(ResourceManager.INFO_CRASH, true, GAME_INFO_APPEAR_DURATION, null);
}
public void showSafeInfo() {
showGameInfo(ResourceManager.INFO_SAFE1, true, new EntityModifierListenerAdapter(){
showGameInfo(ResourceManager.INFO_SAFE1, true, GAME_INFO_APPEAR_DURATION, new EntityModifierListenerAdapter(){
@Override
public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
showGameInfo(ResourceManager.INFO_SAFE2, false, null);
showGameInfo(ResourceManager.INFO_SAFE2, false, GAME_INFO_APPEAR_DURATION, null);
}
});
}
public void showGameInfo(String gameInfoTextureName, boolean animated, IModifierListener<IEntity> entityModifier) {
public void hideGameInfo(String gameInfoTextureName, boolean animated, final IModifierListener<IEntity> entityModifier) {
final Sprite gameInfoSprite = gameInfos.get(gameInfoTextureName);
if (gameInfoSprite.isVisible()) {
if (animated) {
gameInfoSprite.setAlpha(1.0f);
AlphaModifier alphaModifier = new AlphaModifier(GAME_INFO_APPEAR_DURATION, GAME_INFO_FINISH_ALPHA, GAME_INFO_START_ALPHA, EaseStrongOut.getInstance());
alphaModifier.addModifierListener(new IModifierListener<IEntity>() {
@Override
public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) {
if (entityModifier != null) {
entityModifier.onModifierStarted(pModifier, pItem);
}
}
@Override
public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
gameInfoSprite.setVisible(false);
if (entityModifier != null) {
entityModifier.onModifierFinished(pModifier, pItem);
}
}
});
gameInfoSprite.registerEntityModifier(alphaModifier);
} else {
gameInfoSprite.setVisible(false);
}
}
}
public void showGameInfo(String gameInfoTextureName, boolean animated, float animationDuration, IModifierListener<IEntity> entityModifier) {
hideGameInfos();
Sprite gameInfoSprite = gameInfos.get(gameInfoTextureName);
if (animated) {
gameInfoSprite.setAlpha(0);
gameInfoSprite.setVisible(true);
AlphaModifier alphaModifier = new AlphaModifier(GAME_INFO_APPEAR_DURATION, GAME_INFO_START_ALPHA, GAME_INFO_FINISH_ALPHA, EaseStrongOut.getInstance());
AlphaModifier alphaModifier = new AlphaModifier(animationDuration, GAME_INFO_START_ALPHA, GAME_INFO_FINISH_ALPHA, EaseStrongOut.getInstance());
alphaModifier.addModifierListener(entityModifier);
gameInfoSprite.registerEntityModifier(alphaModifier);
} else {
......@@ -805,15 +865,15 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
}
}
private void createCrashInfoSprite(String textureName) {
Sprite gameInfoSprite = new Sprite(MAP_START_POSITION_X + (mapWidgets.get(0).getWidth() / 2),
MAP_START_POSITION_Y - (mapWidgets.get(0).getHeight() / 2),
TILE_SIZE * GAME_INFO_TILE_SIZE_MULTIPLIER,
TILE_SIZE * GAME_INFO_TILE_SIZE_MULTIPLIER,
private void createInfoSprite(GameLayer gameLayer, String textureName, float positionX, float positionY, float width, float height) {
Sprite gameInfoSprite = new Sprite(positionX,
positionY,
width,
height,
ResourceManager.getInstance().getTexture(textureName),
getVertexBufferObjectManager());
gameInfoSprite.setVisible(false);
GameLayer.INFO_LAYER.getLayerEntity().attachChild(gameInfoSprite);
gameLayer.getLayerEntity().attachChild(gameInfoSprite);
gameInfos.put(textureName, gameInfoSprite);
}
......
......@@ -68,7 +68,8 @@ public class ResourceManager {
private static final String ASSET_OBSTACLES = "obstacles/";
public static final String OBSTACLE_DOOR_CLOSED = ASSET_OBSTACLES + "door_closed.png";
public static final String OBSTACLE_DOOR_OPENED = ASSET_OBSTACLES + "door_opened.png";
public static final String OBSTACLE_DOG = ASSET_OBSTACLES + "dog.png";
public static final String OBSTACLE_DOG_SLEEP = ASSET_OBSTACLES + "dog_sleep.png";
public static final String OBSTACLE_DOG_ATTACK = ASSET_OBSTACLES + "dog_attack.png";
private static final String ASSET_ACTIONS = "actions/";
public static final String ACTION_GO = ASSET_ACTIONS + "go.png";
......@@ -84,7 +85,6 @@ public class ResourceManager {
public static final String CONTROL_START_UNPRESSED = ASSET_CONTROL + "start_button_unpressed.png";
public static final String CONTROL_START_DISABLED = ASSET_CONTROL + "start_button_disabled.png";
public static final String CONTROL_ACTUAL = ASSET_CONTROL + "actual.png";
public static final String CONTROL_SEPARATOR = ASSET_CONTROL + "separator.png";
public static final String CONTROL_KEY = ASSET_CONTROL + "key_icon.png";
private static final String ASSET_CREATURE = "creature/";
......@@ -102,6 +102,7 @@ public class ResourceManager {
public static final String INFO_CRASH = ASSET_INFO + "crash.png";
public static final String INFO_SAFE1 = ASSET_INFO + "safe1.png";
public static final String INFO_SAFE2 = ASSET_INFO + "safe2.png";
public static final String INFO_START_ARROW = ASSET_INFO + "start_arrow.png";
private static final String ASSET_SFX_SOURCE = ASSET_GAME + "sfx/";
......@@ -190,7 +191,8 @@ public class ResourceManager {
loadTexture(engine, context, OBSTACLE_DOOR_CLOSED);
loadTexture(engine, context, OBSTACLE_DOOR_OPENED);
loadTiledTexture(engine, context, OBSTACLE_DOG, 5, 2);
loadTexture(engine, context, OBSTACLE_DOG_SLEEP);
loadTexture(engine, context, OBSTACLE_DOG_ATTACK);
loadTexture(engine, context, ACTION_GO);
loadTexture(engine, context, ACTION_LEFT);
......@@ -204,7 +206,6 @@ public class ResourceManager {
loadTexture(engine, context, CONTROL_START_UNPRESSED);
loadTexture(engine, context, CONTROL_START_DISABLED);
loadTexture(engine, context, CONTROL_ACTUAL);
loadTexture(engine, context, CONTROL_SEPARATOR);
loadTexture(engine, context, CONTROL_KEY);
loadTiledTexture(engine, context, CREATURE_PLAYER_WALK_TILED, 4, 2);
......@@ -219,6 +220,7 @@ public class ResourceManager {
loadTexture(engine, context, INFO_CRASH);
loadTexture(engine, context, INFO_SAFE1);
loadTexture(engine, context, INFO_SAFE2);
loadTexture(engine, context, INFO_START_ARROW);
SoundFactory.setAssetBasePath(ASSET_SFX_SOURCE);
......
package cz.nic.tablexia.game.games.potme;
import org.andengine.audio.sound.Sound;
import org.andengine.engine.Engine;
import org.andengine.entity.IEntity;
......@@ -62,7 +63,13 @@ public class UtilityAccess {
}
public void playRandomSoundFromGroup(String[] soundGroup) {
ResourceManager.getInstance().getSound(soundGroup[randomAccess.getRandom().nextInt(soundGroup.length)]).play();
playRandomSoundFromGroup(soundGroup, 1.0f);
};
public void playRandomSoundFromGroup(String[] soundGroup, float rate) {
Sound sound = ResourceManager.getInstance().getSound(soundGroup[randomAccess.getRandom().nextInt(soundGroup.length)]);
sound.setRate(rate);
sound.play();
}
}
......@@ -54,7 +54,7 @@ public class GoActionRule extends AbstractActionTypeRule {
} else if (obstacleInDirection != null && obstacleInDirection.isEnabled()){
crashToTileMapPosition(potmeActivity, true, tileMap, player, mapStartPositionX, mapStartPositionY, actualTileMapPosition, nextTileMapPosition);
playRandomSoundFromGroup(obstacleInDirection.getMapObstacleType().getSoundGroup());
obstacleInDirection.tryToPlayAnimatedObstacleActiveSprite();
obstacleInDirection.reactWithPlayer();
performOnActionFinishWithDelay(player, finishedListener, false, PotmeActivity.ERROR_ACTION_DELAY);
} else {
player.walkToTileMapPosition(tileMap, mapStartPositionX, mapStartPositionY, actualTileMapPosition, nextTileMapPosition, new EntityModifierListenerAdapter() {
......
......@@ -249,15 +249,9 @@ public class ActionsStripWidget extends Entity implements ActionListener {
ACTION_OFFSET + getCurrentActionOffset(0),
ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_ACTUAL),
vertexBufferObjectManager);
Sprite separator = new Sprite(width / 8,
ACTION_OFFSET + (ACTION_OFFSET / 2) + getCurrentActionOffset(0) + PotmeActivity.ACTION_SIZE_BIGGER / 2,
ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_SEPARATOR),
vertexBufferObjectManager);
separator.setWidth(width * 0.7f);
overlay = new Entity();
overlay.attachChild(actualPointer);
overlay.attachChild(separator);
attachChild(overlay);
}
......
......@@ -49,6 +49,7 @@ import cz.nic.tablexia.game.games.potme.map.tile.TileType;
@SuppressLint("RtlHardcoded") // weird behaviour of Eclipse
public class Player extends Entity {
private static final float PLAYER_WALK_SOUND_RATE = 1.2f;
private static final int PLAYER_WALK_ANIMATION_FRAMES = 8;
private static final int PLAYER_JUMP_ANIMATION_FRAMES = 6;
private static final int PLAYER_CRASH_ANIMATION_FRAMES = 7;
......@@ -212,7 +213,7 @@ public class Player extends Entity {
if (modifierListener != null) {
modifierListener.onModifierStarted(modifier, item);
}
UtilityAccess.getInstance().playRandomSoundFromGroup(ResourceManager.STEPS);
UtilityAccess.getInstance().playRandomSoundFromGroup(ResourceManager.STEPS, PLAYER_WALK_SOUND_RATE);
}
@Override
......
......@@ -83,9 +83,11 @@ public class MapObstacle {
}
}
public void tryToPlayAnimatedObstacleActiveSprite() {
public void reactWithPlayer() {
if (mapObstacleActiveSprite != null && mapObstacleType.isAnimated()) {
((AnimatedSprite)mapObstacleActiveSprite).animate(ANIMATION_FRAME_DURATION, false);
} else {
setInactive();
}
}
......
......@@ -36,8 +36,8 @@ public enum MapObstacleType {
DOOR_H(ResourceManager.OBSTACLE_DOOR_CLOSED, false, ResourceManager.OBSTACLE_DOOR_OPENED, 0, ResourceManager.BUMPS, new ArrayList<MapObstaclePosition>(Arrays.asList(new MapObstaclePosition[] {MapObstaclePosition.BOTTOM_POSITION})), 1),
DOOR_V(ResourceManager.OBSTACLE_DOOR_CLOSED, false, ResourceManager.OBSTACLE_DOOR_OPENED, 1, ResourceManager.BUMPS, new ArrayList<MapObstaclePosition>(Arrays.asList(new MapObstaclePosition[] {MapObstaclePosition.LEFT_POSITION})), 1),
DOG_H (ResourceManager.OBSTACLE_DOG, true, null, 0, ResourceManager.BARKS, new ArrayList<MapObstaclePosition>(Arrays.asList(new MapObstaclePosition[] {MapObstaclePosition.BOTTOM_POSITION})), 1.5f),
DOG_V (ResourceManager.OBSTACLE_DOG, true, null, 3, ResourceManager.BARKS, new ArrayList<MapObstaclePosition>(Arrays.asList(new MapObstaclePosition[] {MapObstaclePosition.LEFT_POSITION})), 1.5f);
DOG_H (ResourceManager.OBSTACLE_DOG_SLEEP, false, ResourceManager.OBSTACLE_DOG_ATTACK, 0, ResourceManager.BARKS, new ArrayList<MapObstaclePosition>(Arrays.asList(new MapObstaclePosition[] {MapObstaclePosition.BOTTOM_POSITION})), 1.5f),
DOG_V (ResourceManager.OBSTACLE_DOG_SLEEP, false, ResourceManager.OBSTACLE_DOG_ATTACK, 3, ResourceManager.BARKS, new ArrayList<MapObstaclePosition>(Arrays.asList(new MapObstaclePosition[] {MapObstaclePosition.LEFT_POSITION})), 1.5f);
public enum MapObstaclePosition {
......
......@@ -100,7 +100,7 @@ public class MapWidget extends Entity {
}
public MapWidget(Tile lastFinishTile, MapObjectType finishMapObjetcType, int floorNumber, int positionX, int positionY, int mapXSize, int mapYSize, boolean hasKey, RandomAccess randomAccess, String buttonText, VertexBufferObjectManager vertexBufferObjectManager) {
public MapWidget(Tile lastFinishTile, MapObjectType finishMapObjetcType, int floorNumber, boolean hasBookmark, int positionX, int positionY, int mapXSize, int mapYSize, boolean hasKey, RandomAccess randomAccess, String buttonText, VertexBufferObjectManager vertexBufferObjectManager) {
super();
this.buttonText = buttonText;
this.floorNumber = floorNumber;
......@@ -114,14 +114,18 @@ public class MapWidget extends Entity {
attachChild(mapLayer);
tileMap = new MapGenerator(randomAccess).generateRandomMap(lastFinishTile, mapXSize, mapYSize, finishMapObjetcType, hasKey);
showBookmarkButton(vertexBufferObjectManager);
if (hasBookmark) {
showBookmarkButton(vertexBufferObjectManager);
}
showTileMap(vertexBufferObjectManager);
setPosition(positionX + (getWidth() / 2), positionY + (getHeight() / 2));
}
public void setClickable(boolean clickable) {
bookmarkButton.setClickable(clickable);
if (bookmarkButton != null) {
bookmarkButton.setClickable(clickable);
}
}
public TileMap getTileMap() {
......@@ -130,15 +134,21 @@ public class MapWidget extends Entity {
public void setClickable(Scene scene, TileMapClickListener tileMapClickListener) {
this.tileMapClickListener = tileMapClickListener;
scene.registerTouchArea(bookmarkButton);
if (bookmarkButton != null) {
scene.registerTouchArea(bookmarkButton);
}
}
public void setInFront() {
bookmarkButton.setAlpha(BOOKMARKBUTTON_ALPHA_INFRONT);
if (bookmarkButton != null) {
bookmarkButton.setAlpha(BOOKMARKBUTTON_ALPHA_INFRONT);
}
}
public void setInBottom() {
bookmarkButton.setAlpha(BOOKMARKBUTTON_ALPHA_INBOTTOM);
if (bookmarkButton != null) {
bookmarkButton.setAlpha(BOOKMARKBUTTON_ALPHA_INBOTTOM);
}
}
private void showBookmarkButton(VertexBufferObjectManager vertexBufferObjectManager) {
......
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