Commit 9e91a723 authored by v.tarantik's avatar v.tarantik

Merge branch 'devel' of gitlab.labs.nic.cz:labs/tablexia into devel

parents 7b996aab ddd11b5d
obb/potme/gfx/control/key_icon.png

1.32 KB | W: | H:

obb/potme/gfx/control/key_icon.png

5.33 KB | W: | H:

obb/potme/gfx/control/key_icon.png
obb/potme/gfx/control/key_icon.png
obb/potme/gfx/control/key_icon.png
obb/potme/gfx/control/key_icon.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -53,30 +53,56 @@
android:layout_weight="2"
android:orientation="vertical" >
<ListView
android:id="@+id/screen_encyclopedia_listview_pages"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:clipToPadding="false"
android:paddingTop="5dp" >
</ListView>
android:layout_weight="1" >
<ListView
android:id="@+id/screen_encyclopedia_listview_pages"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollFooter="@drawable/stin_encyklopedie"
android:overScrollHeader="@drawable/stin_encyklopedie"
android:overScrollMode="always"
android:paddingTop="5dp" >
</ListView>
<ImageView
android:id="@+id/screen_encyclopedia_imageView_stin_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/stin_encyklopedie_ud" />
<ImageView
android:id="@+id/screen_encyclopedia_imageView_stin_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/stin_encyklopedie" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center" >
android:gravity="center"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/screen_encyclopedia_fontplus_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/button_fontplus" />
<ImageButton
android:id="@+id/screen_encyclopedia_fontplus_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/button_fontplus" />
<ImageButton
android:id="@+id/screen_encyclopedia_fontminus_button"
......
......@@ -19,14 +19,40 @@
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/screen_encyclopedia_slidingpanel"
android:layout_width="match_parent"
android:keepScreenOn="true"
android:layout_height="match_parent" >
android:layout_height="match_parent"
android:keepScreenOn="true" >
<ListView
android:id="@+id/screen_encyclopedia_listview_pages"
<FrameLayout
android:layout_width="400dp"
android:layout_height="match_parent"
android:background="@color/screen_encyclopedia_background" />
android:background="@color/screen_encyclopedia_background" >
<ListView
android:id="@+id/screen_encyclopedia_listview_pages"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="5dp" >
</ListView>
<ImageView
android:id="@+id/screen_encyclopedia_imageView_stin_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/stin_encyklopedie_ud" />
<ImageView
android:id="@+id/screen_encyclopedia_imageView_stin_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/stin_encyklopedie" />
</FrameLayout>
<android.support.v4.view.ViewPager
xmlns:tools="http://schemas.android.com/tools"
......
......@@ -79,18 +79,30 @@ public class ResourceManager {
public static final String ACTION_DOG = ASSET_ACTIONS + "dog.png";
public static final String ACTION_KEY = ASSET_ACTIONS + "key.png";
private static final String ASSET_CONTROL = "control/";
public static final String CONTROL_NEXT = ASSET_CONTROL + "next.png";
public static final String CONTROL_START = ASSET_CONTROL + "start.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_CONTROL = "control/";
public static final String CONTROL_NEXT = ASSET_CONTROL + "next.png";
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/";
public static final String CREATURE_PLAYER_WALK_TILED = ASSET_CREATURE + "player_walk_tiled.png";
public static final String CREATURE_PLAYER_JUMP_TILED = ASSET_CREATURE + "player_jump_tiled.png";
public static final String CREATURE_PLAYER_CRASH_TILED = ASSET_CREATURE + "player_crash_tiled.png";
private static final String ASSET_BACKGROUND = "background/";
public static final String BACKGROUND_TEXTURE = ASSET_BACKGROUND + "background_texture.jpg";
public static final String BACKGROUND_MAP_DRAWING = ASSET_BACKGROUND + "map_background_drawing.png";
public static final String BACKGROUND_ACTIONSTRIP_TEXTURE = ASSET_BACKGROUND + "actionstrip_background_texture.jpg";
public static final String BACKGROUND_ACTIONS_TEXTURE = ASSET_BACKGROUND + "background_actions_texture.png";
private static final String ASSET_INFO = "info/";
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";
private static final String ASSET_SFX_SOURCE = ASSET_GAME + "sfx/";
......@@ -189,7 +201,8 @@ public class ResourceManager {
loadTexture(engine, context, ACTION_KEY);
loadTexture(engine, context, CONTROL_NEXT);
loadTexture(engine, context, CONTROL_START);
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);
......@@ -198,6 +211,15 @@ public class ResourceManager {
loadTiledTexture(engine, context, CREATURE_PLAYER_JUMP_TILED, 3, 2);
loadTiledTexture(engine, context, CREATURE_PLAYER_CRASH_TILED, 7, 1);
loadTexture(engine, context, BACKGROUND_TEXTURE);
loadTexture(engine, context, BACKGROUND_MAP_DRAWING);
loadTexture(engine, context, BACKGROUND_ACTIONSTRIP_TEXTURE);
loadTexture(engine, context, BACKGROUND_ACTIONS_TEXTURE);
loadTexture(engine, context, INFO_CRASH);
loadTexture(engine, context, INFO_SAFE1);
loadTexture(engine, context, INFO_SAFE2);
SoundFactory.setAssetBasePath(ASSET_SFX_SOURCE);
loadSoundGroup(engine, context, STEPS);
......
......@@ -152,7 +152,7 @@ public class Action extends Sprite {
positionXMoveModifier = null;
}
if (animated) {
positionXMoveModifier = new MoveModifier(ActionsStripWidget.NEXT_ACTION_MOVE_ANIMATION_DURATION,
positionXMoveModifier = new MoveModifier(PotmeActivity.ANIMATION_MOVE_PERIOD,
getX(),
getY(),
positionX,
......
......@@ -109,7 +109,7 @@ public class ActionContainer extends Entity {
reactionRectangleMoveModifier = null;
}
if (animated) {
reactionRectangleMoveModifier = new MoveModifier(ActionsStripWidget.NEXT_ACTION_MOVE_ANIMATION_DURATION,
reactionRectangleMoveModifier = new MoveModifier(PotmeActivity.ANIMATION_MOVE_PERIOD,
0,
reactionRectangle.getY(),
0,
......@@ -162,7 +162,7 @@ public class ActionContainer extends Entity {
actualActionContainerModifier = null;
}
if (animated) {
actualActionContainerModifier = new MoveModifier(ActionsStripWidget.NEXT_ACTION_MOVE_ANIMATION_DURATION,
actualActionContainerModifier = new MoveModifier(PotmeActivity.ANIMATION_MOVE_PERIOD,
getX(),
getY(),
getX(),
......
......@@ -50,8 +50,7 @@ public class DogActionRule extends AbstractActionTypeRule {
MapObstacle obstacleInDirection = ActionUtility.getObstacleInDirection(tileMap, actualTileMapPosition, actualPlayerOrientation);
TileMapPosition nextTileMapPosition = player.getNextTileMapPosition();
if (obstacleInDirection != null && obstacleInDirection.getMapObstacleType() == MapObstacleType.DOG) {
ActionUtility.disbaleObstacleInDirection(tileMap, actualTileMapPosition, actualPlayerOrientation);
if (obstacleInDirection != null && (obstacleInDirection.getMapObstacleType() == MapObstacleType.DOG_H || obstacleInDirection.getMapObstacleType() == MapObstacleType.DOG_V)) {
player.jumpToTileMapPosition(tileMap, mapStartPositionX, mapStartPositionY, actualTileMapPosition, nextTileMapPosition, new EntityModifierListenerAdapter() {
@Override
public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
......@@ -60,6 +59,7 @@ public class DogActionRule extends AbstractActionTypeRule {
});
} else {
playSound(ResourceManager.ERROR);
potmeActivity.showCrashInfo();
performOnActionFinishWithDelay(player, finishedListener, false, PotmeActivity.ERROR_ACTION_DELAY);
}
}
......
......@@ -51,6 +51,7 @@ public class DoorActionRule extends AbstractActionTypeRule {
performOnActionFinished(finishedListener, true);
} else {
playSound(ResourceManager.ERROR);
potmeActivity.showCrashInfo();
performOnActionFinishWithDelay(player, finishedListener, false, PotmeActivity.ERROR_ACTION_DELAY);
}
}
......
......@@ -41,7 +41,7 @@ import cz.nic.tablexia.game.games.potme.map.mapobstacle.MapObstacle;
public class GoActionRule extends AbstractActionTypeRule {
@Override
public void performActionRule(PotmeActivity potmeActivity, TileMap tileMap, Player player, int mapStartPositionX, int mapStartPositionY, final IActionFinishedListener finishedListener) {
public void performActionRule(final PotmeActivity potmeActivity, TileMap tileMap, Player player, int mapStartPositionX, int mapStartPositionY, final IActionFinishedListener finishedListener) {
PlayerOrientation actualPlayerOrientation = player.getActualPlayerOrientation();
TileMapPosition actualTileMapPosition = player.getActualTileMapPosition();
TileMapPosition nextTileMapPosition = player.getNextTileMapPosition();
......@@ -49,10 +49,10 @@ public class GoActionRule extends AbstractActionTypeRule {
MapObstacle obstacleInDirection = ActionUtility.getObstacleInDirection(tileMap, actualTileMapPosition, actualPlayerOrientation);
if (!ActionUtility.checkMoveDirection(tileMap, actualTileMapPosition, nextTileMapPosition)) {
player.crashToTileMapPositionHalfWay(tileMap, mapStartPositionX, mapStartPositionY, actualTileMapPosition, nextTileMapPosition, true, null);
crashToTileMapPosition(potmeActivity, true, tileMap, player, mapStartPositionX, mapStartPositionY, actualTileMapPosition, nextTileMapPosition);
performOnActionFinishWithDelay(player, finishedListener, false, PotmeActivity.ERROR_ACTION_DELAY);
} else if (obstacleInDirection != null && obstacleInDirection.isEnabled()){
player.crashToTileMapPositionHalfWay(tileMap, mapStartPositionX, mapStartPositionY, actualTileMapPosition, nextTileMapPosition, false, null);
crashToTileMapPosition(potmeActivity, true, tileMap, player, mapStartPositionX, mapStartPositionY, actualTileMapPosition, nextTileMapPosition);
playRandomSoundFromGroup(obstacleInDirection.getMapObstacleType().getSoundGroup());
obstacleInDirection.tryToPlayAnimatedObstacleActiveSprite();
performOnActionFinishWithDelay(player, finishedListener, false, PotmeActivity.ERROR_ACTION_DELAY);
......@@ -65,4 +65,16 @@ public class GoActionRule extends AbstractActionTypeRule {
});
}
}
private void crashToTileMapPosition(final PotmeActivity potmeActivity, boolean withSound, TileMap tileMap, Player player, int mapStartPositionX, int mapStartPositionY, TileMapPosition actualTileMapPosition, TileMapPosition nextTileMapPosition) {
player.crashToTileMapPositionHalfWay(tileMap, mapStartPositionX, mapStartPositionY, actualTileMapPosition, nextTileMapPosition, withSound, new EntityModifierListenerAdapter() {
@Override
public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
potmeActivity.showCrashInfo();
}
});
}
}
......@@ -47,6 +47,7 @@ public class KeyActionRule extends AbstractActionTypeRule {
performOnActionFinished(finishedListener, true);
} else {
playSound(ResourceManager.ERROR);
potmeActivity.showCrashInfo();
performOnActionFinishWithDelay(player, finishedListener, false, PotmeActivity.ERROR_ACTION_DELAY);
}
}
......
......@@ -43,6 +43,7 @@ public class StairsActionRule extends AbstractActionTypeRule {
performOnActionFinished(finishedListener, potmeActivity.goToNextFloor(player.getActualTileMapPosition()));
} else {
playSound(ResourceManager.ERROR);
potmeActivity.showCrashInfo();
performOnActionFinishWithDelay(player, finishedListener, false, PotmeActivity.ERROR_ACTION_DELAY);
}
}
......
......@@ -40,7 +40,7 @@ import org.andengine.util.modifier.ease.EaseLinear;
import cz.nic.tablexia.game.games.potme.PotmeActivity;
import cz.nic.tablexia.game.games.potme.ResourceManager;
import cz.nic.tablexia.game.games.potme.UtilityAccess;
import cz.nic.tablexia.game.games.potme.UtilityAccess.IOnDetachListener;
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.ActionListener;
import cz.nic.tablexia.game.games.potme.action.ActionContainer;
......@@ -54,11 +54,10 @@ import cz.nic.tablexia.game.games.potme.action.ActionType;
*/
public class ActionsStripWidget extends Entity implements ActionListener {
private static final float ACTION_DETACH_WIDTH_RATIO = 0.5f;
private static final float MAXIMUM_ACTIONS_COUNT = 200;
public static final float NEXT_ACTION_MOVE_ANIMATION_DURATION = 0.5f;
public static final int ACTION_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER / 10;
private static final int NO_SELECTED_POSITION = -1;
private static final Color BACKGROUND_COLOR = new Color(0.8f, 0.8f, 0.8f);
private static boolean actionsEnabled = true;
private boolean scrollEnabled = true;
......@@ -72,12 +71,14 @@ public class ActionsStripWidget extends Entity implements ActionListener {
private int actualSelectedActionPosition;
private Scene scene;
private StartButton startButton;
private VertexBufferObjectManager vertexBufferObjectManager;
private List<ActionContainer> selectedActions;
private int nextActionFieldActualPosition;
private MoveModifier nextActionFieldMoveModifier;
private MoveModifier scrollPaneMoveModifier;
private int actionOffsetX;
public ActionsStripWidget(int positionX,
int positionY,
......@@ -92,6 +93,7 @@ public class ActionsStripWidget extends Entity implements ActionListener {
this.height = height;
this.scene = scene;
this.vertexBufferObjectManager = vertexBufferObjectManager;
this.actionOffsetX = width / 8;
actualSelectedActionPosition = NO_SELECTED_POSITION;
selectedActions = new ArrayList<ActionContainer>();
......@@ -187,7 +189,7 @@ public class ActionsStripWidget extends Entity implements ActionListener {
}
};
background.setColor(BACKGROUND_COLOR);
background.setColor(Color.TRANSPARENT);
scene.registerTouchArea(background);
attachChild(background);
......@@ -247,11 +249,11 @@ public class ActionsStripWidget extends Entity implements ActionListener {
ACTION_OFFSET + getCurrentActionOffset(0),
ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_ACTUAL),
vertexBufferObjectManager);
Sprite separator = new Sprite(0,
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);
separator.setWidth(width * 0.7f);
overlay = new Entity();
overlay.attachChild(actualPointer);
......@@ -290,7 +292,7 @@ public class ActionsStripWidget extends Entity implements ActionListener {
scrollPaneMoveModifier = null;
}
if (animated) {
scrollPaneMoveModifier = new MoveModifier(NEXT_ACTION_MOVE_ANIMATION_DURATION,
scrollPaneMoveModifier = new MoveModifier(PotmeActivity.ANIMATION_MOVE_PERIOD,
scrollPane.getX(),
scrollPane.getY(),
scrollPane.getX(),
......@@ -318,12 +320,12 @@ public class ActionsStripWidget extends Entity implements ActionListener {
/* //////////////////////////////////////////// NEXT ACTION FIELD */
private void createNextActionField() {
nextActionField = new Sprite(-ACTION_OFFSET,
0,
PotmeActivity.ACTION_SIZE_BIGGER,
PotmeActivity.ACTION_SIZE_BIGGER,
ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_NEXT),
vertexBufferObjectManager);
nextActionField = new Sprite(actionOffsetX,
0,
PotmeActivity.ACTION_SIZE_BIGGER,
PotmeActivity.ACTION_SIZE_BIGGER,
ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_NEXT),
vertexBufferObjectManager);
nextActionFieldReactionArea = new Rectangle(nextActionField.getWidth() / 2,
height / 2,
......@@ -357,7 +359,7 @@ public class ActionsStripWidget extends Entity implements ActionListener {
nextActionFieldMoveModifier = null;
}
if (animated) {
nextActionFieldMoveModifier = new MoveModifier(NEXT_ACTION_MOVE_ANIMATION_DURATION,
nextActionFieldMoveModifier = new MoveModifier(PotmeActivity.ANIMATION_MOVE_PERIOD,
nextActionField.getX(),
nextActionField.getY(),
nextActionField.getX(),
......@@ -404,7 +406,33 @@ public class ActionsStripWidget extends Entity implements ActionListener {
selectedActions.get(collisionNumber).resetReactionRectangle(true);
}
}
/* //////////////////////////////////////////// START BUTTON */
public void setStartButton(StartButton startButton) {
this.startButton = startButton;
}
private void enableStartButton() {
if (startButton != null && !startButton.isEnbleda()) {
startButton.enable();
}
}
private void disableStartButton() {
if (startButton != null && startButton.isEnbleda()) {
startButton.disable();
}
}
public void setStartButtonState() {
if (selectedActions.size() > 0) {
enableStartButton();
} else {
disableStartButton();
}
}
/* //////////////////////////////////////////// ACTIONS */
......@@ -468,6 +496,8 @@ public class ActionsStripWidget extends Entity implements ActionListener {
// move next action field
moveNextActionFieldPermanently(selectedActions.size(), animatedNextActionField);
setStartButtonState();
}
}
......@@ -486,6 +516,8 @@ public class ActionsStripWidget extends Entity implements ActionListener {
moveScrollPaneBottomToAction(0, null, true);
}
}
setStartButtonState();
}
public List<ActionContainer> getSelectedActions() {
......@@ -503,7 +535,7 @@ public class ActionsStripWidget extends Entity implements ActionListener {
}
private ActionContainer createActionContainer(Action action) {
return new ActionContainer(-ACTION_OFFSET,
return new ActionContainer(actionOffsetX,
action,
height / 2,
vertexBufferObjectManager);
......@@ -522,7 +554,7 @@ public class ActionsStripWidget extends Entity implements ActionListener {
private Float lastPositonX = null;
private Float lastPositonY = null;
private float detachLimit = -width * 2/3;
private float detachLimit = -width * ACTION_DETACH_WIDTH_RATIO;
@Override
protected boolean downAction() {
......@@ -560,14 +592,8 @@ public class ActionsStripWidget extends Entity implements ActionListener {
if (!detached) {
detached = true;
resizeWithAnimation((float)PotmeActivity.ACTION_SIZE_SMALLER);
UtilityAccess.getInstance().detachAndAttachEntity(this, ActionsStripWidget.this, new IOnDetachListener() {
@Override
public void onDetach() {
removeAction(getOrderNumber());
}
},
false);
UtilityAccess.getInstance().detachAndAttachEntity(this, ActionsStripWidget.this, null, false);
removeAction(getOrderNumber());
}
super.dragAction(dragPositionX, dragPositionY);
result = true;
......
......@@ -24,11 +24,14 @@ import java.util.List;
import org.andengine.entity.Entity;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import android.os.Handler;
import cz.nic.tablexia.game.games.potme.PotmeActivity;
import cz.nic.tablexia.game.games.potme.PotmeDifficulty;
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.ActionListener;
import cz.nic.tablexia.game.games.potme.action.ActionType;
......@@ -41,9 +44,11 @@ import cz.nic.tablexia.game.games.potme.action.ActionType;
*/
public class ActionsWidget extends Entity implements ActionListener {
private static final int START_ANIMATION_DELAY = 200;
private static final int NUMBER_OF_COLUMNS = 2;
private static final int ACTION_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER / 10;
private static final float BACKGROUND_WIDTH_RATIO = 1.3f;
private static final double BACKGROUND_Y_POSITION_RATIO = 0.9;
private static final int START_ANIMATION_DELAY = 200;
private static final int NUMBER_OF_COLUMNS = 2;
public static final int ACTION_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER / 10;
private ActionsStripWidget actionsStripWidget;
private List<Action> actions;
......@@ -59,6 +64,17 @@ public class ActionsWidget extends Entity implements ActionListener {
this.actions = new ArrayList<Action>();
List<ActionType> actionTypes = ActionType.getActionTypesForGameDifficulty(potmeDifficulty);
ITextureRegion backgroundTexture = ResourceManager.getInstance().getTexture(ResourceManager.BACKGROUND_ACTIONS_TEXTURE);
int backgroundWidth = (int)((NUMBER_OF_COLUMNS * PotmeActivity.ACTION_SIZE_SMALLER) * BACKGROUND_WIDTH_RATIO);
int backgroundHeight = (int)(backgroundWidth * (backgroundTexture.getHeight() / backgroundTexture.getWidth()));
Sprite actionsBackground = new Sprite((NUMBER_OF_COLUMNS * (PotmeActivity.ACTION_SIZE_SMALLER + (2 * ACTION_OFFSET))) / 2,
-(int)((((Math.round(actionTypes.size() / 2) + (actionTypes.size() % 2)) * (PotmeActivity.ACTION_SIZE_SMALLER)) / 2) * BACKGROUND_Y_POSITION_RATIO),
backgroundWidth,
backgroundHeight,
backgroundTexture, vertexBufferObjectManager);
attachChild(actionsBackground);
for (int i = 0; i < actionTypes.size(); i++) {
createAction(actionTypes.get(i), i, false, scene);
}
......
......@@ -34,6 +34,7 @@ import org.andengine.util.modifier.IModifier;
import org.andengine.util.modifier.ease.EaseCubicInOut;
import android.annotation.SuppressLint;
import cz.nic.tablexia.game.games.potme.PotmeActivity;
import cz.nic.tablexia.game.games.potme.ResourceManager;
import cz.nic.tablexia.game.games.potme.UtilityAccess;
import cz.nic.tablexia.game.games.potme.map.TileMap;
......@@ -48,7 +49,6 @@ 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_ANIMATION_DURATION = 0.6f;
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;
......@@ -141,14 +141,14 @@ public class Player extends Entity {
public void setPossibleDirection(TileMap tileMap) {
if (actualTileMapPosition != null) {
TileType tileType = tileMap.getTileAtPosition(actualTileMapPosition).getTileType();
if (tileType.isRightDoor()) {
setPlayerOrientation(PlayerOrientation.RIGHT, null, false);
if (tileType.isLeftDoor()) {
setPlayerOrientation(PlayerOrientation.LEFT, null, false);
} else if (tileType.isTopDoor()) {
setPlayerOrientation(PlayerOrientation.TOP, null, false);
} else if (tileType.isBottomDoor()) {
setPlayerOrientation(PlayerOrientation.BOTTOM, null, false);
} else if (tileType.isLeftDoor()) {
setPlayerOrientation(PlayerOrientation.LEFT, null, false);
} else if (tileType.isRightDoor()) {
setPlayerOrientation(PlayerOrientation.RIGHT, null, false);
}
}
}
......@@ -188,8 +188,8 @@ public class Player extends Entity {
if (modifierListener != null) {
modifierListener.onModifierStarted(pModifier, pItem);
}
registerEntityModifier(new SequenceEntityModifier(new ScaleModifier(PLAYER_ANIMATION_DURATION / 2, 1f, PLAYER_JUMP_SCALE, EaseCubicInOut.getInstance()),
new ScaleModifier(PLAYER_ANIMATION_DURATION / 2, PLAYER_JUMP_SCALE, 1f, EaseCubicInOut.getInstance())));
registerEntityModifier(new SequenceEntityModifier(new ScaleModifier(PotmeActivity.ANIMATION_MOVE_PERIOD / 2, 1f, PLAYER_JUMP_SCALE, EaseCubicInOut.getInstance()),
new ScaleModifier(PotmeActivity.ANIMATION_MOVE_PERIOD / 2, PLAYER_JUMP_SCALE, 1f, EaseCubicInOut.getInstance())));
UtilityAccess.getInstance().playRandomSoundFromGroup(ResourceManager.JUMPS);
}
......@@ -248,6 +248,7 @@ public class Player extends Entity {
TileMapPosition centerPositionForNextTile = tileMap.getCenterPositionForTile(nextPlayerPosition.getPositionX(), nextPlayerPosition.getPositionY());
finishDestinationX = mapStartPositionX + centerPositionForNextTile.getPositionX() + finishPositionCenterOffsetX;
finishDestinationY = mapStartPositionY - centerPositionForNextTile.getPositionY() + finishPositionCenterOffsetY;
actualTileMapPosition = new TileMapPosition(nextPlayerPosition.getPositionX(), nextPlayerPosition.getPositionY());
}
Path pathToTravel = new Path(2).to(mapStartPositionX + centerPositionForCurrentTile.getPositionX() + (getWidth() / 2),
......@@ -255,7 +256,7 @@ public class Player extends Entity {
finishDestinationY);
float animationDuration = halfWay ? (PLAYER_ANIMATION_DURATION / 2) : PLAYER_ANIMATION_DURATION;
float animationDuration = halfWay ? (PotmeActivity.ANIMATION_MOVE_PERIOD / 2) : PotmeActivity.ANIMATION_MOVE_PERIOD;
registerEntityModifier(new PathModifier(animationDuration, pathToTravel, new IEntityModifierListener() {
@Override
......@@ -263,7 +264,7 @@ public class Player extends Entity {
if (modifierListener != null) {
modifierListener.onModifierStarted(modifier, item);
}
actualPlayerSprite.animate((long)((PLAYER_ANIMATION_DURATION / framesNumber) * 1000), false, new IAnimationListener() {
actualPlayerSprite.animate((long)((PotmeActivity.ANIMATION_MOVE_PERIOD / framesNumber) * 1000), false, new IAnimationListener() {
@Override
public void onAnimationStarted(AnimatedSprite pAnimatedSprite, int pInitialLoopCount) {}
......@@ -298,7 +299,6 @@ public class Player extends Entity {
}
}));
actualTileMapPosition = new TileMapPosition(nextPlayerPosition.getPositionX(), nextPlayerPosition.getPositionY());
return true;
}
......@@ -371,7 +371,7 @@ public class Player extends Entity {
} else if (actualPlayerOrientation == PlayerOrientation.TOP && playerOrientation == PlayerOrientation.LEFT) {
fromRotation = fullCircle;
}
actualPlayerSprite.registerEntityModifier(new RotationModifier(PLAYER_ANIMATION_DURATION / 4, fromRotation, toRotation, modifierListener));
actualPlayerSprite.registerEntityModifier(new RotationModifier(PotmeActivity.ANIMATION_MOVE_PERIOD / 4, fromRotation, toRotation, modifierListener));
} else {
actualPlayerSprite.setRotation(toRotation);
}
......