Commit 4e22eb95 authored by Lukas Marik's avatar Lukas Marik

#945 set center point for object, scale some objects textures, repair put...

#945 set center point for object, scale some objects textures, repair put object on wall for bonus difficulty
parent 55e039a7
......@@ -916,7 +916,7 @@ public class ProtocolGame extends AbstractTablexiaGame<ProtocolGameState> {
}
private WallType isAtWallBehindFurniture(Color touchColor){
return FurnitureType.getFurnitureWallByColor(touchColor);
return FurnitureType.getFurnitureWallByColor(touchColor, getGameDifficulty());
}
private Color getColorByClick(float x, float y) {
......
......@@ -128,15 +128,15 @@ public class GameObject extends ObjectModel {
//////////////////////////// INITIALIZATION
public void initPoints(){
float xCenter = objectImage.getDrawable().getMinWidth() * type.getCenterRatio()[0];
float yCenter = objectImage.getDrawable().getMinHeight() * type.getCenterRatio()[1];
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
float xCenter = minWidth * type.getCenterRatio()[0];
float yCenter = minHeight * type.getCenterRatio()[1];
centerPosition = new Vector2(xCenter, yCenter);
float[] pointRatio = type.getPutRatio();
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
if(pointRatio != null) {
putPoint = new Vector2(minWidth * pointRatio[0], minHeight * pointRatio[1]);
}
......@@ -149,6 +149,25 @@ public class GameObject extends ObjectModel {
}
}
private void changePointsPosition(){
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
setPositionForPoint(centerPosition, minWidth, minHeight, type.getCenterRatio());
setPositionForPoint(putPoint, minWidth, minHeight, type.getPutRatio());
setPositionForPoint(wallPoint, minWidth, minHeight, type.getWallRatio());
}
private void setPositionForPoint(Vector2 point, float minWidth, float minHeight, float[] positionRatio){
if(point == null || positionRatio == null)
return;
point.x = (rotate ? (1.f - minWidth * positionRatio[0]) : minWidth * positionRatio[1]);
point.y = minHeight * positionRatio[1];
}
private void initEdgePoint(WallObjectDescriptor descriptor){
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
......@@ -285,6 +304,7 @@ public class GameObject extends ObjectModel {
public void rotateObject(boolean rotate){
this.rotate = rotate;
objectDrawable.flip(rotate ^ objectDrawable.isFlipX(), false);
changePointsPosition();
if(canPutOnPosition(RoomPosition.WALL))
initEdgePoint(WallObjectDescriptor.getDescriptorByType(type));
......
......@@ -17,11 +17,14 @@
package cz.nic.tablexia.game.games.protocol.gameobjects;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import cz.nic.tablexia.game.games.protocol.controller.RoomPosition;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
/**
* Created by lmarik on 14.8.17.
......@@ -44,6 +47,13 @@ public abstract class ObjectModel extends Group {
return new Vector2(getX() + centerPosition.x, getY() + centerPosition.y);
}
protected Image createPoint(Vector2 position, Color color){
Image point = new Image(ApplicationAtlasManager.getInstance().getColorTexture(color));
point.setBounds(position.x - 2.5f, position.y - 2.5f, 5f, 5f);
addActor(point);
return point;
}
public Vector2 getPutPointScreenPosition() {
return null;
}
......
......@@ -24,10 +24,14 @@ import cz.nic.tablexia.game.games.protocol.gameobjects.GameObjectType;
import cz.nic.tablexia.game.games.protocol.gameobjects.wall.WallType;
public enum WallObjectDescriptor {
CUCKOO_CLOCK (GameObjectType.CUCKOO_CLOCK, WallType.LEFT_WALL, new float[]{0.06f, 0.97f}, new float[]{0.1f, 0.03f}, new float[]{0.92f, 0.98f}, new float[]{0.93f, 0.04f}, Arrays.asList( new float[]{0.044f, 0.55f}, new float[]{0.42f, 0.87f}, new float[]{0.92f, 0.65f})),
LADY_AND_PANDA (GameObjectType.LADY_AND_PANDA, WallType.LEFT_WALL, new float[]{0.11f, 0.68f}, new float[]{0.19f, 0.04f}, new float[]{0.86f, 0.94f}, new float[]{0.93f, 0.31f}, Arrays.asList( new float[]{0.08f, 0.66f}, new float[]{0.45f, 0.8f}, new float[]{0.92f, 0.65f})),
LANDSCAPE (GameObjectType.LANDSCAPE, WallType.RIGHT_WALL, new float[]{0.09f, 0.93f}, new float[]{0.08f, 0.38f}, new float[]{0.9f, 0.62f}, new float[]{0.9f, 0.05f}, Arrays.asList( new float[]{0.08f, 0.66f}, new float[]{0.57f, 0.87f}, new float[]{0.92f, 0.65f})),
MIRROR (GameObjectType.MIRROR, WallType.RIGHT_WALL, new float[]{0.2f, 0.97f}, new float[]{0.07f, 0.18f}, new float[]{0.91f, 0.82f}, new float[]{0.74f, 0.03f}, Arrays.asList( new float[]{0.08f, 0.52f}, new float[]{0.5f, 0.78f}, new float[]{0.92f, 0.52f}));
CUCKOO_CLOCK (GameObjectType.CUCKOO_CLOCK, WallType.LEFT_WALL, new float[]{0.06f, 0.97f}, new float[]{0.1f, 0.03f}, new float[]{0.92f, 0.98f}, new float[]{0.93f, 0.04f}, Arrays.asList( new float[]{0.044f, 0.55f}, new float[]{0.42f, 0.87f}, new float[]{0.92f, 0.65f})),
LADY_AND_PANDA (GameObjectType.LADY_AND_PANDA, WallType.LEFT_WALL, new float[]{0.11f, 0.68f}, new float[]{0.19f, 0.04f}, new float[]{0.86f, 0.94f}, new float[]{0.93f, 0.31f}, Arrays.asList( new float[]{0.08f, 0.66f}, new float[]{0.45f, 0.8f}, new float[]{0.92f, 0.65f})),
LANDSCAPE (GameObjectType.LANDSCAPE, WallType.RIGHT_WALL, new float[]{0.09f, 0.93f}, new float[]{0.08f, 0.38f}, new float[]{0.9f, 0.62f}, new float[]{0.9f, 0.05f}, Arrays.asList( new float[]{0.08f, 0.66f}, new float[]{0.57f, 0.87f}, new float[]{0.92f, 0.65f})),
MIRROR (GameObjectType.MIRROR, WallType.RIGHT_WALL, new float[]{0.2f, 0.97f}, new float[]{0.07f, 0.18f}, new float[]{0.91f, 0.82f}, new float[]{0.74f, 0.03f}, Arrays.asList( new float[]{0.08f, 0.52f}, new float[]{0.5f, 0.78f}, new float[]{0.92f, 0.52f})),
KABUKI (GameObjectType.KABUKI, WallType.LEFT_WALL, new float[]{0.2f, 0.97f}, new float[]{0.07f, 0.18f}, new float[]{0.91f, 0.82f}, new float[]{0.74f, 0.03f}, Arrays.asList( new float[]{0.08f, 0.52f}, new float[]{0.5f, 0.78f}, new float[]{0.92f, 0.52f})),
MASK_AFRICA (GameObjectType.MASK_AFRICA, WallType.RIGHT_WALL, new float[]{0.2f, 0.97f}, new float[]{0.07f, 0.18f}, new float[]{0.91f, 0.82f}, new float[]{0.74f, 0.03f}, Arrays.asList( new float[]{0.08f, 0.52f}, new float[]{0.5f, 0.78f}, new float[]{0.92f, 0.52f})),
TRAVEL_HAT (GameObjectType.TRAVEL_HAT, WallType.LEFT_WALL, new float[]{0.2f, 0.97f}, new float[]{0.07f, 0.18f}, new float[]{0.91f, 0.82f}, new float[]{0.74f, 0.03f}, Arrays.asList( new float[]{0.08f, 0.52f}, new float[]{0.5f, 0.78f}, new float[]{0.92f, 0.52f}));
private GameObjectType objectType;
private WallType wallOrientation;
......
......@@ -52,22 +52,24 @@ public enum FurnitureType implements TypeObjectDescriptor {
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, null, new float[]{0.5f,0.483f}, new float[]{0.562f,0.065f}, new float[]{0.5f,0.8f}, new Color(0x004466ff)),
//BONUS
BONUS_BIG_SHELF_LEFT (ProtocolAssets.BIG_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.BONUS, RoomPosition.WALL, WallType.LEFT_WALL, new float[]{0.2106f, 0.7402f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x5900b3ff)),
BONUS_BIG_SHELF_RIGHT (ProtocolAssets.BIG_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.BONUS, RoomPosition.WALL, WallType.RIGHT_WALL, new float[]{0.5909f,0.7402f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0xff6600ff)),
BONUS_BIG_TABLE (ProtocolAssets.BIG_TABLE, ProtocolAssets.F_TABLE_B_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, null, new float[]{0.5258f,0.0268f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x000080ff)),
BONUS_CABINET_LEFT (ProtocolAssets.CABINET_LEFT, ProtocolAssets.F_CABINET_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, WallType.LEFT_WALL, new float[]{0.2636f,0.4784f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x996600ff)),
BONUS_CABINET_RIGHT (ProtocolAssets.CABINET_RIGHT, ProtocolAssets.F_CABINET_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, WallType.RIGHT_WALL, new float[]{0.8576f,0.2887f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x7f0000ff)),
BONUS_CHEST_OF_DRAWERS_LEFT (ProtocolAssets.CHEST_OF_DRAWERS_LEFT, ProtocolAssets.F_CHEST_OF_DRAWERS_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, WallType.LEFT_WALL, new float[]{0.0182f, 0.2619f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x009965ff)),
BONUS_CHEST_OF_DRAWERS_RIGHT (ProtocolAssets.CHEST_OF_DRAWERS_RIGHT, ProtocolAssets.F_CHEST_OF_DRAWERS_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, WallType.RIGHT_WALL, new float[]{0.6909f,0.3278f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x570061ff)),
BONUS_ROUND_TABLE (ProtocolAssets.ROUND_TABLE, ProtocolAssets.F_TABLE_S_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, null, new float[]{0.4394f,0.4845f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x212022ff)),
BONUS_SMALL_SHELF_LEFT (ProtocolAssets.SMALL_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.BONUS, RoomPosition.WALL, WallType.LEFT_WALL, new float[]{0.1152f,0.6598f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x003300ff)),
BONUS_SMALL_SHELF_RIGHT (ProtocolAssets.SMALL_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.BONUS, RoomPosition.WALL, WallType.RIGHT_WALL, new float[]{0.8379f,0.6144f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x5c5c8aff)),
BONUS_SMALL_TABLE (ProtocolAssets.SMALL_TABLE, ProtocolAssets.F_TABLE_S_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, null, new float[]{0.1742f,0.2268f}, new float[]{0.5f, 0.5f}, new float[]{0.5f, 0.5f}, new Color(0x004466ff));
BONUS_BIG_SHELF_LEFT (ProtocolAssets.BIG_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.BONUS, RoomPosition.WALL, WallType.LEFT_WALL, new float[]{0.2106f, 0.7402f}, new float[]{0.29f,0.064f}, new float[]{0.55f,0.56f}, new Color(0x5900b3ff)),
BONUS_BIG_SHELF_RIGHT (ProtocolAssets.BIG_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.BONUS, RoomPosition.WALL, WallType.RIGHT_WALL, new float[]{0.5909f,0.7402f}, new float[]{0.714f,0.123f}, new float[]{0.5f,0.55f}, new Color(0xff6600ff)),
BONUS_BIG_TABLE (ProtocolAssets.BIG_TABLE, ProtocolAssets.F_TABLE_B_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, null, new float[]{0.5258f,0.0268f}, new float[]{0.41f, 0.05f}, new float[]{0.5f, 0.5f}, new Color(0x000080ff)),
BONUS_CABINET_LEFT (ProtocolAssets.CABINET_LEFT, ProtocolAssets.F_CABINET_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, WallType.LEFT_WALL, new float[]{0.2636f,0.4784f}, new float[]{0.94f, 0.24f}, new float[]{0.5f, 0.5f}, new Color(0x996600ff)),
BONUS_CHEST_OF_DRAWERS_LEFT (ProtocolAssets.CHEST_OF_DRAWERS_LEFT, ProtocolAssets.F_CHEST_OF_DRAWERS_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, WallType.LEFT_WALL, new float[]{0.0182f, 0.2619f}, new float[]{0.97f, 0.29f}, new float[]{0.52f,0.83f}, new Color(0x009965ff)),
BONUS_CHEST_OF_DRAWERS_RIGHT (ProtocolAssets.CHEST_OF_DRAWERS_RIGHT, ProtocolAssets.F_CHEST_OF_DRAWERS_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, WallType.RIGHT_WALL, new float[]{0.6909f,0.3278f}, new float[]{0.034f,0.29f}, new float[]{0.5f,0.81f}, new Color(0x570061ff)),
BONUS_CABINET_RIGHT (ProtocolAssets.CABINET_RIGHT, ProtocolAssets.F_CABINET_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, WallType.RIGHT_WALL, new float[]{0.8576f,0.2887f}, new float[]{0.05f, 0.24f}, new float[]{0.5f, 0.5f}, new Color(0x7f0000ff)),
BONUS_ROUND_TABLE (ProtocolAssets.ROUND_TABLE, ProtocolAssets.F_TABLE_S_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, null, new float[]{0.4394f,0.4845f}, new float[]{0.52f, 0.02f}, new float[]{0.5f, 0.5f}, new Color(0x212022ff)),
BONUS_SMALL_SHELF_LEFT (ProtocolAssets.SMALL_SHELF_LEFT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.BONUS, RoomPosition.WALL, WallType.LEFT_WALL, new float[]{0.1152f,0.6598f}, new float[]{0.327f,0.107f}, new float[]{0.54f,0.52f}, new Color(0x003300ff)),
BONUS_SMALL_SHELF_RIGHT (ProtocolAssets.SMALL_SHELF_RIGHT, ProtocolAssets.F_SHELF_TEXT, GameDifficulty.BONUS, RoomPosition.WALL, WallType.RIGHT_WALL, new float[]{0.8379f,0.6144f}, new float[]{0.667f,0.097f}, new float[]{0.54f,0.52f}, new Color(0x5c5c8aff)),
BONUS_SMALL_TABLE (ProtocolAssets.SMALL_TABLE, ProtocolAssets.F_TABLE_S_TEXT, GameDifficulty.BONUS, RoomPosition.FLOOR, null, new float[]{0.1742f,0.2268f}, new float[]{0.5f, 0.02f}, new float[]{0.5f, 0.5f}, new Color(0x004466ff));
private static final int MEDIUM_RANGE_MIN = 0;
private static final int MEDIUM_RANGE_MAX = 6;
private static final int HARD_RANGE_MIN = 6;
private static final int HARD_RANGE_MAX = 14;
private static final int BONUS_RANGE_MIN = 14;
private static final int BONUS_RANGE_MAX = 25;
private String pathResource;
......@@ -141,9 +143,22 @@ public enum FurnitureType implements TypeObjectDescriptor {
return null;
}
public static WallType getFurnitureWallByColor(Color color){
List<FurnitureType> leftFurniture = Arrays.asList(MEDIUM_BIG_SHELF_LEFT, MEDIUM_CHEST_OF_DRAWERS_LEFT, MEDIUM_SMALL_SHELF_LEFT);
List<FurnitureType> rightFurniture = Arrays.asList(MEDIUM_BIG_SHELF_RIGHT, MEDIUM_CHEST_OF_DRAWERS_RIGHT, MEDIUM_SMALL_SHELF_RIGHT);
public static WallType getFurnitureWallByColor(Color color, GameDifficulty difficulty){
List<FurnitureType> leftFurniture;
List<FurnitureType> rightFurniture;
switch (difficulty){
case MEDIUM:
leftFurniture = Arrays.asList(MEDIUM_BIG_SHELF_LEFT, MEDIUM_CHEST_OF_DRAWERS_LEFT, MEDIUM_SMALL_SHELF_LEFT);
rightFurniture = Arrays.asList(MEDIUM_BIG_SHELF_RIGHT, MEDIUM_CHEST_OF_DRAWERS_RIGHT, MEDIUM_SMALL_SHELF_RIGHT);
break;
case BONUS:
leftFurniture = Arrays.asList(BONUS_BIG_SHELF_LEFT, BONUS_SMALL_SHELF_LEFT);
rightFurniture = Arrays.asList(BONUS_BIG_SHELF_RIGHT, BONUS_SMALL_SHELF_RIGHT);
break;
default:
return null;
}
for(FurnitureType furniture: leftFurniture){
if(furniture.colorInMap.equals(color))
......@@ -162,8 +177,8 @@ public enum FurnitureType implements TypeObjectDescriptor {
if(difficulty == GameDifficulty.EASY)
return null;
int min = difficulty == GameDifficulty.MEDIUM ? MEDIUM_RANGE_MIN : HARD_RANGE_MIN;
int max = difficulty == GameDifficulty.MEDIUM ? MEDIUM_RANGE_MAX : HARD_RANGE_MAX;
int min = difficulty == GameDifficulty.MEDIUM ? MEDIUM_RANGE_MIN : difficulty == GameDifficulty.HARD ? HARD_RANGE_MIN : BONUS_RANGE_MIN;
int max = difficulty == GameDifficulty.MEDIUM ? MEDIUM_RANGE_MAX : difficulty == GameDifficulty.HARD ? HARD_RANGE_MAX : BONUS_RANGE_MAX;
return new ArrayList<>(Arrays.asList(values())).subList(min,max);
}
......
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