Commit c1a238ac authored by Lukas Marik's avatar Lukas Marik

#945 set fix wall ratio, set wall poit for bonus wall objects and change wall...

#945 set fix wall ratio, set wall poit for bonus wall objects and change wall position when object rotate, can put object under furniture, repair globe inflection
parent 84fa0e19
......@@ -868,13 +868,11 @@ public class ProtocolGame extends AbstractTablexiaGame<ProtocolGameState> {
WallType wallType = null;
if(putPoint != null) {
Color putColor = getColorByClick(putPoint.x, putPoint.y);
furnitureType = isAtFurniture(putColor);
furnitureType = isAtFurniture(putPoint);
}
if(wallPoint != null) {
Color wallColor = getColorByClick(wallPoint.x, wallPoint.y);
wallType = isAtWall(wallColor);
wallType = isAtWall(wallPoint);
}
//1. Check furniture position
......@@ -884,7 +882,6 @@ public class ProtocolGame extends AbstractTablexiaGame<ProtocolGameState> {
//2. Check floor position
if(isAtFloor(centerColor)){
//object move to floor
return new PositionTransfer(RoomPosition.FLOOR, null, null);
}
......@@ -893,7 +890,7 @@ public class ProtocolGame extends AbstractTablexiaGame<ProtocolGameState> {
return new PositionTransfer(RoomPosition.WALL, null, wallType);
}
return null;
return FurnitureType.canPutObjectUnderFurnitures(centerColor, getGameDifficulty()) ? new PositionTransfer(RoomPosition.FLOOR, null, null) : null;
}
private boolean isAtFloor(Color touchColor) {
......@@ -902,21 +899,23 @@ public class ProtocolGame extends AbstractTablexiaGame<ProtocolGameState> {
touchColor.equals(Color.GREEN));
}
private FurnitureType isAtFurniture(Color touchColor) {
private FurnitureType isAtFurniture(Vector2 checkPoint) {
Color touchColor = getColorByClick(checkPoint.x, checkPoint.y);
return FurnitureType.getFurnitureTypeByColor(touchColor, getGameDifficulty());
}
private WallType isAtWall(Color touchColor) {
private WallType isAtWall(Vector2 checkPoint) {
Color touchColor = getColorByClick(checkPoint.x, checkPoint.y);
WallType wallType = WallType.getWallTypeByColor(touchColor);
if(wallType == null)
wallType = isAtWallBehindFurniture(touchColor);
wallType = isAtWallBehindFurniture(touchColor, checkPoint);
return wallType;
}
private WallType isAtWallBehindFurniture(Color touchColor){
return FurnitureType.getFurnitureWallByColor(touchColor, getGameDifficulty());
private WallType isAtWallBehindFurniture(Color touchColor, Vector2 objectPoint){
return FurnitureType.getFurnitureWallByColor(touchColor, objectPoint , roomGroup.getWidth(), roomGroup.getHeight(), getGameDifficulty());
}
private Color getColorByClick(float x, float y) {
......
......@@ -151,24 +151,23 @@ public class GameObject extends ObjectModel {
}
//TODO opravit put point pri rotaci obrazu
/*private void changePointsPosition(){
private void changeWallPointPosition(){
if(type.getWallRatio() == null)
return;
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
if(!middle) {
wallPoint.x = minWidth * (rotate ? (1f - type.getWallRatio()[0]) : type.getWallRatio()[0]);
wallPoint.y = minHeight * type.getWallRatio()[1];
}else {
wallPoint.x = minWidth / 2;
wallPoint.y = minHeight / 2;
}
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();
......@@ -307,10 +306,11 @@ public class GameObject extends ObjectModel {
public void rotateObject(boolean rotate){
this.rotate = rotate;
objectDrawable.flip(rotate ^ objectDrawable.isFlipX(), false);
//changePointsPosition();
if(canPutOnPosition(RoomPosition.WALL))
if(canPutOnPosition(RoomPosition.WALL)) {
changeWallPointPosition();
initEdgePoint(WallObjectDescriptor.getDescriptorByType(type));
}
}
public void middleTexture(boolean useMiddleTexture){
......
......@@ -26,13 +26,13 @@ import cz.nic.tablexia.game.games.protocol.gameobjects.wall.WallType;
public enum WallObjectDescriptor {
//MEDIUM
CUCKOO_CLOCK (GameObjectType.CUCKOO_CLOCK, WallType.LEFT_WALL, new EdgePoints(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 EdgePoints(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})),
LADY_AND_PANDA (GameObjectType.LADY_AND_PANDA, WallType.LEFT_WALL, new EdgePoints(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 EdgePoints(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 EdgePoints(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})),
//BONUS
KABUKI (GameObjectType.KABUKI, WallType.LEFT_WALL, new EdgePoints(new float[]{0.07f, 0.9f}, new float[]{0.1f, -0.13f}, new float[]{0.9f, 1.07f}, new float[]{0.93f, 0.13f}), 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 EdgePoints(new float[]{0.1f, 1.04f}, new float[]{0.07f, 0.12f}, new float[]{0.95f, 0.9f}, new float[]{0.74f, -0.02f}), 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 EdgePoints(new float[]{0.1f, 0.88f}, new float[]{0.1f, -0.1f}, new float[]{0.87f, 1.1f}, new float[]{0.87f, 0.15f}), 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 EdgePoints(new float[]{0.07f, 0.9f}, new float[]{0.1f, -0.13f}, new float[]{0.9f, 1.07f}, new float[]{0.93f, 0.13f}), Arrays.asList( new float[]{0.04f, 0.75f}, new float[]{0.6f, 0.78f}, new float[]{0.83f, 0.74f})),
MASK_AFRICA (GameObjectType.MASK_AFRICA, WallType.RIGHT_WALL, new EdgePoints(new float[]{0.1f, 1.04f}, new float[]{0.07f, 0.12f}, new float[]{0.95f, 0.9f}, new float[]{0.74f, -0.02f}), Arrays.asList( new float[]{0.04f, 0.75f}, new float[]{0.4f, 0.78f}, new float[]{0.83f, 0.74f})),
TRAVEL_HAT (GameObjectType.TRAVEL_HAT, WallType.LEFT_WALL, new EdgePoints(new float[]{0.1f, 0.88f}, new float[]{0.1f, -0.1f}, new float[]{0.87f, 1.1f}, new float[]{0.87f, 0.15f}), Arrays.asList( new float[]{0.04f, 0.75f}, new float[]{0.5f, 0.9f}, new float[]{0.83f, 0.74f}));
private GameObjectType objectType;
......
......@@ -18,9 +18,11 @@
package cz.nic.tablexia.game.games.protocol.gameobjects.furniture;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
......@@ -54,7 +56,7 @@ public enum FurnitureType implements TypeObjectDescriptor {
//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.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.6f, 0.76f}, new Color(0x000080ff)),
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.1f}, new float[]{0.6f, 0.76f}, 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.6f, 0.84f}, 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.35f,0.72f}, 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.48f,0.8f}, new Color(0x570061ff)),
......@@ -62,7 +64,7 @@ public enum FurnitureType implements TypeObjectDescriptor {
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.42f, 0.78f}, 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.45f, 0.74f}, new Color(0x004466ff));
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.06f}, new float[]{0.45f, 0.74f}, new Color(0x004466ff));
private static final int MEDIUM_RANGE_MIN = 0;
private static final int MEDIUM_RANGE_MAX = 6;
......@@ -143,7 +145,7 @@ public enum FurnitureType implements TypeObjectDescriptor {
return null;
}
public static WallType getFurnitureWallByColor(Color color, GameDifficulty difficulty){
public static WallType getFurnitureWallByColor(Color color, Vector2 objectPoint, float w, float h, GameDifficulty difficulty){
List<FurnitureType> leftFurniture;
List<FurnitureType> rightFurniture;
......@@ -161,18 +163,44 @@ public enum FurnitureType implements TypeObjectDescriptor {
}
for(FurnitureType furniture: leftFurniture){
if(furniture.colorInMap.equals(color))
return WallType.LEFT_WALL;
if(furniture.colorInMap.equals(color)) {
Vector2 wallPoint = WallType.LEFT_WALL.getEdgePointsByDifficulty(difficulty).getrTPoint(w,h);
return wallPoint.x >= objectPoint.x ? WallType.LEFT_WALL : WallType.MIDDLE_WALL;
}
}
for(FurnitureType furniture: rightFurniture){
if(furniture.colorInMap.equals(color))
return WallType.RIGHT_WALL;
if(furniture.colorInMap.equals(color)) {
Vector2 wallPoint = WallType.RIGHT_WALL.getEdgePointsByDifficulty(difficulty).getlTPoint(w,h);
return wallPoint.x <= objectPoint.x ? WallType.RIGHT_WALL : WallType.MIDDLE_WALL;
}
}
return null;
}
public static boolean canPutObjectUnderFurnitures(Color color, GameDifficulty difficulty){
List<FurnitureType> floorFurniture;
switch (difficulty){
case HARD:
floorFurniture = Collections.singletonList(HARD_BIG_TABLE);
break;
case BONUS:
floorFurniture = Arrays.asList(BONUS_BIG_TABLE, BONUS_SMALL_TABLE);
break;
default:
return false;
}
for(FurnitureType furnitureType: floorFurniture){
if(furnitureType.colorInMap.equals(color))
return true;
}
return false;
}
public static List<FurnitureType> getFurnitureByDifficulty(GameDifficulty difficulty){
if(difficulty == GameDifficulty.EASY)
return null;
......
......@@ -131,7 +131,7 @@ public class CZProtocolGenerator extends ProtocolGenerator {
//BONUS
BAG (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, null, null, CZObjectDescriptor.InflectionType.ZENA, null)),
BIG_BOOK (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, new AbstractObjectDescriptor.Adjective[]{AbstractObjectDescriptor.Adjective.BIG}, CZObjectDescriptor.AdjectiveInflection.FM, CZObjectDescriptor.InflectionType.ZENA, null)),
BIG_GLOBE (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, new AbstractObjectDescriptor.Adjective[]{AbstractObjectDescriptor.Adjective.BIG}, CZObjectDescriptor.AdjectiveInflection.FM, CZObjectDescriptor.InflectionType.ZENA, null)),
BIG_GLOBE (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.M, AbstractObjectDescriptor.NounType.SINGULAR, new AbstractObjectDescriptor.Adjective[]{AbstractObjectDescriptor.Adjective.BIG}, CZObjectDescriptor.AdjectiveInflection.MM, CZObjectDescriptor.InflectionType.HRAD, null)),
BROWN_BOOK (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, new AbstractObjectDescriptor.Adjective[]{AbstractObjectDescriptor.Adjective.BROWN}, CZObjectDescriptor.AdjectiveInflection.FM, CZObjectDescriptor.InflectionType.ZENA, null)),
ELEPHANT (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, null, null, CZObjectDescriptor.InflectionType.ZENA, ProtocolAssets.ELEPHANT)),
GIRAFFE (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, null, null, CZObjectDescriptor.InflectionType.ZENA, ProtocolAssets.GIRAFFE)),
......@@ -143,7 +143,7 @@ public class CZProtocolGenerator extends ProtocolGenerator {
MASK_AFRICA (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, new AbstractObjectDescriptor.Adjective[]{AbstractObjectDescriptor.Adjective.AFRICA}, CZObjectDescriptor.AdjectiveInflection.FM, CZObjectDescriptor.InflectionType.ZENA, null)),
SHELLS (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, null, null, CZObjectDescriptor.InflectionType.RUZE, ProtocolAssets.WITH_SHELLS)),
SMALL_BOOK (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, new AbstractObjectDescriptor.Adjective[]{AbstractObjectDescriptor.Adjective.SMALL}, CZObjectDescriptor.AdjectiveInflection.FM, CZObjectDescriptor.InflectionType.ZENA, null)),
SMALL_GLOBE (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.F, AbstractObjectDescriptor.NounType.SINGULAR, new AbstractObjectDescriptor.Adjective[]{AbstractObjectDescriptor.Adjective.SMALL}, CZObjectDescriptor.AdjectiveInflection.FM, CZObjectDescriptor.InflectionType.ZENA, null)),
SMALL_GLOBE (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.M, AbstractObjectDescriptor.NounType.SINGULAR, new AbstractObjectDescriptor.Adjective[]{AbstractObjectDescriptor.Adjective.SMALL}, CZObjectDescriptor.AdjectiveInflection.MM, CZObjectDescriptor.InflectionType.HRAD, null)),
STACK_OF_BOOKS (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.M, AbstractObjectDescriptor.NounType.SINGULAR, null, null, CZObjectDescriptor.InflectionType.HRAD, ProtocolAssets.OF_BOOKS)),
STAND_FOR_POSTER (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.M, AbstractObjectDescriptor.NounType.SINGULAR, null, null, CZObjectDescriptor.InflectionType.HRAD, ProtocolAssets.WITH_POSTERS)),
TABLE_WITH_MAPS (new CZObjectDescriptor(AbstractObjectDescriptor.Voice.M, AbstractObjectDescriptor.NounType.SINGULAR, null, null, CZObjectDescriptor.InflectionType.HRAD, ProtocolAssets.WITH_MAPS)),
......
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