Commit c9508b67 authored by Lukas Marik's avatar Lukas Marik

#940 rotate object on furniture

parent 0d784506
...@@ -285,7 +285,9 @@ public class GameObject extends ObjectModel { ...@@ -285,7 +285,9 @@ public class GameObject extends ObjectModel {
public void rotateObject(boolean rotate){ public void rotateObject(boolean rotate){
this.rotate = rotate; this.rotate = rotate;
objectDrawable.flip(rotate ^ objectDrawable.isFlipX(), false); objectDrawable.flip(rotate ^ objectDrawable.isFlipX(), false);
initEdgePoint(WallObjectDescriptor.getDescriptorByType(type));
if(canPutOnPosition(RoomPosition.WALL))
initEdgePoint(WallObjectDescriptor.getDescriptorByType(type));
} }
public void middleTexture(boolean useMiddleTexture){ public void middleTexture(boolean useMiddleTexture){
......
...@@ -36,21 +36,21 @@ import cz.nic.tablexia.game.games.protocol.gameobjects.wall.WallType; ...@@ -36,21 +36,21 @@ import cz.nic.tablexia.game.games.protocol.gameobjects.wall.WallType;
public enum FurnitureType implements TypeObjectDescriptor { public enum FurnitureType implements TypeObjectDescriptor {
//MEDIUM //MEDIUM
MEDIUM_BIG_SHELF_LEFT (ProtocolAssets.BIG_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.MEDIUM, RoomPosition.WALL , new float[]{0.14f,0.64f}, new float[]{0.82f,0.802f}, new float[]{0.5f,0.52f}, new Color(0x5900b3ff)), MEDIUM_BIG_SHELF_LEFT (ProtocolAssets.BIG_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.MEDIUM, RoomPosition.WALL, WallType.LEFT_WALL, new float[]{0.14f,0.64f}, new float[]{0.82f,0.802f}, new float[]{0.5f,0.52f}, new Color(0x5900b3ff)),
MEDIUM_BIG_SHELF_RIGHT (ProtocolAssets.BIG_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.MEDIUM, RoomPosition.WALL, new float[]{0.62f,0.66f}, new float[]{0.15f,0.76f}, new float[]{0.5f,0.52f}, new Color(0xff6600ff)), MEDIUM_BIG_SHELF_RIGHT (ProtocolAssets.BIG_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.MEDIUM, RoomPosition.WALL, WallType.RIGHT_WALL, new float[]{0.62f,0.66f}, new float[]{0.15f,0.76f}, new float[]{0.5f,0.52f}, new Color(0xff6600ff)),
MEDIUM_CHEST_OF_DRAWERS_LEFT (ProtocolAssets.CHEST_OF_DRAWERS_LEFT, ProtocolAssets.F_CHEST_OF_DRAWERS_TEXT, GameDifficulty.MEDIUM, RoomPosition.FLOOR, new float[]{0.05f,0.3f}, new float[]{0.89f,0.201f}, new float[]{0.5f,0.82f}, new Color(0x996600ff)), MEDIUM_CHEST_OF_DRAWERS_LEFT (ProtocolAssets.CHEST_OF_DRAWERS_LEFT, ProtocolAssets.F_CHEST_OF_DRAWERS_TEXT, GameDifficulty.MEDIUM, RoomPosition.FLOOR, WallType.LEFT_WALL, new float[]{0.05f,0.3f}, new float[]{0.89f,0.201f}, new float[]{0.5f,0.82f}, new Color(0x996600ff)),
MEDIUM_CHEST_OF_DRAWERS_RIGHT (ProtocolAssets.CHEST_OF_DRAWERS_RIGHT, ProtocolAssets.F_CHEST_OF_DRAWERS_TEXT, GameDifficulty.MEDIUM, RoomPosition.FLOOR, new float[]{0.825f,0.27f}, new float[]{0.12f,0.228f}, new float[]{0.5f,0.82f}, new Color(0x7f0000ff)), MEDIUM_CHEST_OF_DRAWERS_RIGHT (ProtocolAssets.CHEST_OF_DRAWERS_RIGHT, ProtocolAssets.F_CHEST_OF_DRAWERS_TEXT, GameDifficulty.MEDIUM, RoomPosition.FLOOR, WallType.RIGHT_WALL, new float[]{0.825f,0.27f}, new float[]{0.12f,0.228f}, new float[]{0.5f,0.82f}, new Color(0x7f0000ff)),
MEDIUM_SMALL_SHELF_LEFT (ProtocolAssets.SMALL_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.MEDIUM, RoomPosition.WALL, new float[]{0.22f,0.52f}, new float[]{0.76f,0.74f}, new float[]{0.5f,0.54f}, new Color(0x003300ff)), MEDIUM_SMALL_SHELF_LEFT (ProtocolAssets.SMALL_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.MEDIUM, RoomPosition.WALL, WallType.LEFT_WALL, new float[]{0.22f,0.52f}, new float[]{0.76f,0.74f}, new float[]{0.5f,0.54f}, new Color(0x003300ff)),
MEDIUM_SMALL_SHELF_RIGHT (ProtocolAssets.SMALL_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.MEDIUM, RoomPosition.WALL, new float[]{0.62f,0.55f}, new float[]{0.267f,0.598f}, new float[]{0.5f,0.52f}, new Color(0x5c5c8aff)), MEDIUM_SMALL_SHELF_RIGHT (ProtocolAssets.SMALL_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.MEDIUM, RoomPosition.WALL, WallType.RIGHT_WALL, new float[]{0.62f,0.55f}, new float[]{0.267f,0.598f}, new float[]{0.5f,0.52f}, new Color(0x5c5c8aff)),
//HARD //HARD
HARD_BIG_SHELF_LEFT (ProtocolAssets.BIG_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.HARD, RoomPosition.WALL, new float[]{0.026f,0.578f}, new float[]{0.29f,0.064f}, new float[]{0.55f,0.56f}, new Color(0x5900b3ff)), HARD_BIG_SHELF_LEFT (ProtocolAssets.BIG_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.HARD, RoomPosition.WALL, WallType.LEFT_WALL, new float[]{0.026f,0.578f}, new float[]{0.29f,0.064f}, new float[]{0.55f,0.56f}, new Color(0x5900b3ff)),
HARD_BIG_SHELF_RIGHT (ProtocolAssets.BIG_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.HARD, RoomPosition.WALL, new float[]{0.585f,0.694f}, new float[]{0.714f,0.123f}, new float[]{0.5f,0.55f}, new Color(0xff6600ff)), HARD_BIG_SHELF_RIGHT (ProtocolAssets.BIG_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.HARD, RoomPosition.WALL, WallType.RIGHT_WALL, new float[]{0.585f,0.694f}, new float[]{0.714f,0.123f}, new float[]{0.5f,0.55f}, new Color(0xff6600ff)),
HARD_BIG_TABLE (ProtocolAssets.BIG_TABLE, ProtocolAssets.F_TABLE_B_TEXT, GameDifficulty.HARD, RoomPosition.FLOOR, new float[]{0.141f,0.118f}, new float[]{0.546f,0.05f}, new float[]{0.48f,0.75f}, new Color(0x000080ff)), HARD_BIG_TABLE (ProtocolAssets.BIG_TABLE, ProtocolAssets.F_TABLE_B_TEXT, GameDifficulty.HARD, RoomPosition.FLOOR, null, new float[]{0.141f,0.118f}, new float[]{0.546f,0.05f}, new float[]{0.48f,0.75f}, new Color(0x000080ff)),
HARD_CHEST_OF_DRAWERS_LEFT (ProtocolAssets.CHEST_OF_DRAWERS_LEFT, ProtocolAssets.F_CABINET_TEXT, GameDifficulty.HARD, RoomPosition.FLOOR, new float[]{0.268f,0.481f}, new float[]{0.937f,0.204f}, new float[]{0.52f,0.83f}, new Color(0x996600ff)), HARD_CHEST_OF_DRAWERS_LEFT (ProtocolAssets.CHEST_OF_DRAWERS_LEFT, ProtocolAssets.F_CABINET_TEXT, GameDifficulty.HARD, RoomPosition.FLOOR, WallType.LEFT_WALL, new float[]{0.268f,0.481f}, new float[]{0.937f,0.204f}, new float[]{0.52f,0.83f}, new Color(0x996600ff)),
HARD_CHEST_OF_DRAWERS_RIGHT (ProtocolAssets.CHEST_OF_DRAWERS_RIGHT, ProtocolAssets.F_CABINET_TEXT, GameDifficulty.HARD, RoomPosition.FLOOR, new float[]{0.723f,0.384f}, new float[]{0.082f,0.215f}, new float[]{0.5f,0.81f}, new Color(0x7f0000ff)), HARD_CHEST_OF_DRAWERS_RIGHT (ProtocolAssets.CHEST_OF_DRAWERS_RIGHT, ProtocolAssets.F_CABINET_TEXT, GameDifficulty.HARD, RoomPosition.FLOOR, WallType.RIGHT_WALL, new float[]{0.723f,0.384f}, new float[]{0.082f,0.215f}, new float[]{0.5f,0.81f}, new Color(0x7f0000ff)),
HARD_SMALL_SHELF_LEFT (ProtocolAssets.SMALL_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.HARD, RoomPosition.WALL, new float[]{0.047f,0.452f}, new float[]{0.327f,0.107f}, new float[]{0.52f,0.54f}, new Color(0x003300ff)), HARD_SMALL_SHELF_LEFT (ProtocolAssets.SMALL_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.HARD, RoomPosition.WALL, WallType.LEFT_WALL, new float[]{0.047f,0.452f}, new float[]{0.327f,0.107f}, new float[]{0.52f,0.54f}, new Color(0x003300ff)),
HARD_SMALL_SHELF_RIGHT (ProtocolAssets.SMALL_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.HARD, RoomPosition.WALL, new float[]{0.841f,0.607f}, new float[]{0.667f,0.097f}, new float[]{0.54f,0.52f}, new Color(0x5c5c8aff)), HARD_SMALL_SHELF_RIGHT (ProtocolAssets.SMALL_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.HARD, RoomPosition.WALL, WallType.RIGHT_WALL, new float[]{0.841f,0.607f}, new float[]{0.667f,0.097f}, new float[]{0.54f,0.52f}, new Color(0x5c5c8aff)),
HARD_SMALL_TABLE (ProtocolAssets.SMALL_TABLE, ProtocolAssets.F_TABLE_S_TEXT, GameDifficulty.HARD, RoomPosition.FLOOR, new float[]{0.5f,0.483f}, new float[]{0.562f,0.065f}, new float[]{0.5f,0.8f}, new Color(0x004466ff)); HARD_SMALL_TABLE (ProtocolAssets.SMALL_TABLE, ProtocolAssets.F_TABLE_S_TEXT, GameDifficulty.HARD, RoomPosition.FLOOR, null, new float[]{0.5f,0.483f}, new float[]{0.562f,0.065f}, new float[]{0.5f,0.8f}, new Color(0x004466ff));
private static final int MEDIUM_RANGE_MIN = 0; private static final int MEDIUM_RANGE_MIN = 0;
...@@ -63,16 +63,18 @@ public enum FurnitureType implements TypeObjectDescriptor { ...@@ -63,16 +63,18 @@ public enum FurnitureType implements TypeObjectDescriptor {
private String textResource; private String textResource;
private GameDifficulty difficulty; private GameDifficulty difficulty;
private RoomPosition mapPosition; private RoomPosition mapPosition;
private WallType wallOrientation;
private float[] positionRation; private float[] positionRation;
private float[] middleRatio; private float[] middleRatio;
private float[] fixPositionRatio; private float[] fixPositionRatio;
private Color colorInMap; private Color colorInMap;
FurnitureType(String pathResource, String textResource, GameDifficulty difficulty, RoomPosition mapPosition, float[] positionRatio, float[] middleRatio, float[] fixPositionRatio, Color colorInMap) { FurnitureType(String pathResource, String textResource, GameDifficulty difficulty, RoomPosition mapPosition, WallType wallOrientation, float[] positionRatio, float[] middleRatio, float[] fixPositionRatio, Color colorInMap) {
this.pathResource = pathResource; this.pathResource = pathResource;
this.textResource = textResource; this.textResource = textResource;
this.difficulty = difficulty; this.difficulty = difficulty;
this.mapPosition = mapPosition; this.mapPosition = mapPosition;
this.wallOrientation = wallOrientation;
this.positionRation = positionRatio; this.positionRation = positionRatio;
this.middleRatio = middleRatio; this.middleRatio = middleRatio;
this.fixPositionRatio = fixPositionRatio; this.fixPositionRatio = fixPositionRatio;
...@@ -105,6 +107,10 @@ public enum FurnitureType implements TypeObjectDescriptor { ...@@ -105,6 +107,10 @@ public enum FurnitureType implements TypeObjectDescriptor {
return fixPositionRatio; return fixPositionRatio;
} }
public WallType getWallOrientation() {
return wallOrientation;
}
public static List<FurnitureType> getFurnitureTypesByDifficulty(GameDifficulty difficulty){ public static List<FurnitureType> getFurnitureTypesByDifficulty(GameDifficulty difficulty){
List<FurnitureType> types = new ArrayList<>(); List<FurnitureType> types = new ArrayList<>();
for (FurnitureType type: values()){ for (FurnitureType type: values()){
......
...@@ -104,6 +104,8 @@ public class RoomGroup extends Group { ...@@ -104,6 +104,8 @@ public class RoomGroup extends Group {
furniture.addObjectOnFurniture(gameObject, xPosition, yPosition); furniture.addObjectOnFurniture(gameObject, xPosition, yPosition);
gameObject.setFurniture(furniture); gameObject.setFurniture(furniture);
controlRotateOnFurniture(gameObject, furnitureType);
} else if(roomPosition == RoomPosition.WALL && wallType != null){ } else if(roomPosition == RoomPosition.WALL && wallType != null){
addObjectToWall(gameObject, wallType, roomPosition, xPosition, yPosition); addObjectToWall(gameObject, wallType, roomPosition, xPosition, yPosition);
...@@ -266,20 +268,37 @@ public class RoomGroup extends Group { ...@@ -266,20 +268,37 @@ public class RoomGroup extends Group {
WallType wallType = positionTransfer.getWallType(); WallType wallType = positionTransfer.getWallType();
if ((position == RoomPosition.WALL || previousPosition == RoomPosition.WALL) && wallType != changedObject.getWallPositionType()) { if (position == RoomPosition.WALL && wallType != changedObject.getWallPositionType()) {
WallObjectDescriptor descriptor = WallObjectDescriptor.getDescriptorByType(changedObject.getType()); WallObjectDescriptor descriptor = WallObjectDescriptor.getDescriptorByType(changedObject.getType());
changedObject.middleTexture(wallType == WallType.MIDDLE_WALL); changedObject.middleTexture(wallType == WallType.MIDDLE_WALL);
changedObject.rotateObject((position == RoomPosition.WALL) && (descriptor.getWallOrientation() != wallType && wallType != WallType.MIDDLE_WALL)); changedObject.rotateObject((descriptor.getWallOrientation() != wallType && wallType != WallType.MIDDLE_WALL));
} else if (position == RoomPosition.FURNITURE) {
changedObject.middleTexture(false);
controlRotateOnFurniture(changedObject, positionTransfer.getFurnitureType());
} else if (position == RoomPosition.FLOOR) {
changedObject.middleTexture(false);
changedObject.rotateObject(false);
} }
if (position == RoomPosition.WALL) if (position == RoomPosition.WALL)
controlWallPosition(changedObject, wallType); controlWallPosition(changedObject, wallType);
changedObject.setRoomPosition(position); changedObject.setRoomPosition(position);
changedObject.setWallPositionType(wallType); changedObject.setWallPositionType(wallType);
controlObjectsPosition(changedObject); controlObjectsPosition(changedObject);
} }
private void controlRotateOnFurniture(GameObject gameObject, FurnitureType furnitureType){
if(!gameObject.canPutOnPosition(RoomPosition.WALL))
return;
WallType objectWallOrientation = WallObjectDescriptor.getDescriptorByType(gameObject.getType()).getWallOrientation();
WallType furnitureWallOrientation = furnitureType.getWallOrientation();
gameObject.rotateObject(objectWallOrientation != furnitureWallOrientation);
}
private void controlWallPosition(GameObject gameObject, WallType wallType) { private void controlWallPosition(GameObject gameObject, WallType wallType) {
Vector2 lBObject = new Vector2(gameObject.getX() + gameObject.getlBPoint().x, gameObject.getY() + gameObject.getlBPoint().y); Vector2 lBObject = new Vector2(gameObject.getX() + gameObject.getlBPoint().x, gameObject.getY() + gameObject.getlBPoint().y);
Vector2 lTObject = new Vector2(gameObject.getX() + gameObject.getlTPoint().x, gameObject.getY() + gameObject.getlTPoint().y); Vector2 lTObject = new Vector2(gameObject.getX() + gameObject.getlTPoint().x, gameObject.getY() + gameObject.getlTPoint().y);
......
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