Commit 7a5dd0a7 authored by Aneta Steimarova's avatar Aneta Steimarova

Merge branch 'V3.7' into feature-itest-in-the-darkness

parents 5fbd7310 8eb52e8e
......@@ -69,6 +69,9 @@ game_protocol_descriptor_verb_is_p = jsou
game_protocol_descriptor_verb_lie_s = leží
game_protocol_descriptor_verb_lie_p = leží
game_protocol_descriptor_verb_hang_s = visí
game_protocol_descriptor_verb_hang_p = visí
game_protocol_descriptor_pronoun_m_l_s =
game_protocol_descriptor_pronoun_m_l_p = ří
......
......@@ -85,6 +85,9 @@ game_protocol_descriptor_verb_is_p = sind
game_protocol_descriptor_verb_lie_s = liegt
game_protocol_descriptor_verb_lie_p = liegen
game_protocol_descriptor_verb_hang_s = hängt
game_protocol_descriptor_verb_hang_p = hängen
game_protocol_easy_angel = Engel
game_protocol_easy_baby_carriage = Wagen
game_protocol_easy_bag_of_marbles = Murmelbeutel
......
......@@ -69,6 +69,9 @@ game_protocol_descriptor_verb_is_p = sú
game_protocol_descriptor_verb_lie_s = leží
game_protocol_descriptor_verb_lie_p = leží
game_protocol_descriptor_verb_hang_s = visí
game_protocol_descriptor_verb_hang_p = visí
game_protocol_descriptor_pronoun_m_s =
game_protocol_descriptor_pronoun_f_s =
game_protocol_descriptor_pronoun_n_s =
......
Subproject commit 5afacc743c05cc8a95df68a91f13ceb93d8ba0e2
Subproject commit d48f0101969ce29b45e73d3184133ed4b18fa964
......@@ -50,6 +50,7 @@ import cz.nic.tablexia.game.games.protocol.controller.PositionCounter;
import cz.nic.tablexia.game.games.protocol.gameobjects.GameObject;
import cz.nic.tablexia.game.games.protocol.gameobjects.GameObjectType;
import cz.nic.tablexia.game.games.protocol.gameobjects.ObjectModel;
import cz.nic.tablexia.game.games.protocol.gameobjects.descriptors.WallObjectDescriptor;
import cz.nic.tablexia.game.games.protocol.gameobjects.wall.WallType;
import cz.nic.tablexia.game.games.protocol.model.CardsWidget;
import cz.nic.tablexia.game.games.protocol.model.RoomGroup;
......@@ -526,7 +527,9 @@ public class ProtocolGame extends AbstractTablexiaGame<ProtocolGameState> {
addGameObjectToRoom(object, xPosition, yPosition, new PositionTransfer(RoomPosition.FURNITURE, furnitureType, null));
} else if (positionPairs.get(0).getObjectType() instanceof WallType) {
WallType wallType = (WallType) positionPairs.get(0).getObjectType();
float[] fixRatio = wallType.getFixRatio(getGameDifficulty());
WallObjectDescriptor descriptor = WallObjectDescriptor.getDescriptorByType(objectType);
float[] fixRatio = descriptor.getFixRatio(wallType);
float xPosition = roomGroup.getWidth() * fixRatio[0] - object.getWallPoint().x;
float yPosition = roomGroup.getHeight() * fixRatio[1] - object.getWallPoint().y;
......
......@@ -22,6 +22,7 @@ import com.badlogic.gdx.math.Vector2;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
......@@ -46,6 +47,7 @@ public class ObjectsController {
public static final int HORIZONTAL_CIRCULAR_SECTOR = 65;
private Map<GameObjectType, List<PositionPair>> solution = new HashMap<>();
private List<GameObjectType> objectsOnWall = new LinkedList<>();
public ObjectsController() {
......@@ -63,10 +65,18 @@ public class ObjectsController {
solution.put(keyObject, new ArrayList<>());
}
solution.get(keyObject).add(new PositionPair(preposition, valueObject));
if(valueObject instanceof WallType)
objectsOnWall.add(keyObject);
}
public void clearSolution() {
solution.clear();
objectsOnWall.clear();
}
public boolean isObjectOnWall(GameObjectType objectType){
return objectsOnWall.contains(objectType);
}
//////////////////////////// OBJECTS CONTROL
......
......@@ -30,6 +30,7 @@ import com.badlogic.gdx.utils.Align;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.game.games.protocol.ProtocolGame;
import cz.nic.tablexia.game.games.protocol.controller.RoomPosition;
import cz.nic.tablexia.game.games.protocol.gameobjects.descriptors.WallObjectDescriptor;
import cz.nic.tablexia.game.games.protocol.gameobjects.furniture.Furniture;
import cz.nic.tablexia.game.games.protocol.gameobjects.wall.WallType;
import cz.nic.tablexia.game.games.protocol.utils.ProtocolDragListener;
......@@ -56,6 +57,7 @@ public class GameObject extends ObjectModel {
private static final Interpolation CARD_INTERPOLATION = Interpolation.swingOut;
private static final Interpolation BIGGER_INTERPOLATION = Interpolation.linear;
private static final String MIDDLE_PREFIX = "_m";
private static final float MOVE_DURATION = 0.3f;
private static final float SMALL_DURATION = 0.235f;
private static final float BIGGER_DURATION = 0.08f;
......@@ -83,6 +85,11 @@ public class GameObject extends ObjectModel {
private WallType wallPositionType;
private Vector2 positionBeforeScale;
//Wall control points;
private Vector2 rBPoint;
private Vector2 lBPoint;
private Vector2 lTPoint;
private Vector2 rTPoint;
private TablexiaLabel descriptionLabel;
private TextureRegion cardDrawable;
......@@ -94,6 +101,8 @@ public class GameObject extends ObjectModel {
private boolean selected;
private boolean fixed;
private boolean scaling;
private boolean rotate;
private boolean middle;
public GameObject(GameObjectType type, ProtocolGame protocolGame, String cardText, boolean inPicture) {
this.type = type;
......@@ -104,6 +113,8 @@ public class GameObject extends ObjectModel {
roomPosition = null;
selected = false;
fixed = false;
rotate = false;
middle = false;
cardDrawable = protocolGame.getScreenTextureRegion(type.getCardTexturePath());
objectDrawable = protocolGame.getScreenTextureRegion(type.getObjectTexturePath());
......@@ -123,15 +134,42 @@ public class GameObject extends ObjectModel {
float[] pointRatio = type.getPutRatio();
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
if(pointRatio != null) {
putPoint = new Vector2(objectImage.getDrawable().getMinWidth() * pointRatio[0], objectImage.getDrawable().getMinHeight() * pointRatio[1]);
putPoint = new Vector2(minWidth * pointRatio[0], minHeight * pointRatio[1]);
}
float[] wallRatio = type.getWallRatio();
if(wallRatio != null){
wallPoint = new Vector2(objectImage.getDrawable().getMinWidth() * wallRatio[0], objectImage.getDrawable().getMinHeight() * wallRatio[1]);
wallPoint = new Vector2(minWidth * wallRatio[0], minHeight * wallRatio[1]);
initEdgePoint(WallObjectDescriptor.getDescriptorByType(type));
}
}
private void initEdgePoint(WallObjectDescriptor descriptor){
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
if(!middle) {
rBPoint = new Vector2(minWidth * (rotate ? (1.f - descriptor.getlBRatio()[0]) : descriptor.getrBRatio()[0]), minHeight * (rotate ? descriptor.getlBRatio()[1] : descriptor.getrBRatio()[1]));
rTPoint = new Vector2(minWidth * (rotate ? (1.f - descriptor.getlTRatio()[0]) : descriptor.getrTRatio()[0]), minHeight * (rotate ? descriptor.getlTRatio()[1] : descriptor.getrTRatio()[1]));
lBPoint = new Vector2(minWidth * (rotate ? (1.f - descriptor.getrBRatio()[0]) : descriptor.getlBRatio()[0]), minHeight * (rotate ? descriptor.getrBRatio()[1] : descriptor.getlBRatio()[1]));
lTPoint = new Vector2(minWidth * (rotate ? (1.f - descriptor.getrTRatio()[0]) : descriptor.getlTRatio()[0]), minHeight * (rotate ? descriptor.getrTRatio()[1] : descriptor.getlTRatio()[1]));
}else {
float topRatio = 0.97f;
float bottomRatio = 0.04f;
rBPoint = new Vector2(minWidth * topRatio, minHeight * bottomRatio);
rTPoint = new Vector2(minWidth * topRatio, minHeight * topRatio);
lBPoint = new Vector2(minWidth * bottomRatio, minHeight * bottomRatio);
lTPoint = new Vector2(minWidth * bottomRatio, minHeight * topRatio);
}
}
public void initDragListener() {
......@@ -231,7 +269,8 @@ public class GameObject extends ObjectModel {
public void moveToPosition(boolean anim, float xPosition, float yPosition, Runnable finishAction) {
if (anim) {
addAction(sequence(moveTo(xPosition, yPosition, DROP_ANIM_DURATION, CARD_INTERPOLATION), run(finishAction)));
if(finishAction != null) addAction(sequence(moveTo(xPosition, yPosition, DROP_ANIM_DURATION, CARD_INTERPOLATION), run(finishAction)));
else addAction(sequence(moveTo(xPosition, yPosition, DROP_ANIM_DURATION, CARD_INTERPOLATION)));
} else {
setPosition(xPosition, yPosition);
}
......@@ -243,6 +282,24 @@ public class GameObject extends ObjectModel {
return type.checkPosition(position);
}
public void rotateObject(boolean rotate){
this.rotate = rotate;
objectDrawable.flip(rotate ^ objectDrawable.isFlipX(), false);
if(canPutOnPosition(RoomPosition.WALL))
initEdgePoint(WallObjectDescriptor.getDescriptorByType(type));
}
public void middleTexture(boolean useMiddleTexture){
if(middle == useMiddleTexture)
return;
objectDrawable = protocolGame.getScreenTextureRegion(type.getObjectTexturePath() + (useMiddleTexture ? MIDDLE_PREFIX : ""));
objectImage.setDrawable(new TextureRegionDrawable(objectDrawable));
changeSize();
this.middle = useMiddleTexture;
}
//////////////////////////// SCALE ACTIONS
......@@ -403,6 +460,26 @@ public class GameObject extends ObjectModel {
return scaling;
}
public boolean isRotate() {
return rotate;
}
public Vector2 getrBPoint() {
return rBPoint;
}
public Vector2 getlBPoint() {
return lBPoint;
}
public Vector2 getlTPoint() {
return lTPoint;
}
public Vector2 getrTPoint() {
return rTPoint;
}
@Override
public TypeObjectDescriptor getTypePosition() {
return furniture != null ? furniture.getType() : null;
......
......@@ -128,7 +128,8 @@ public abstract class AbstractObjectDescriptor {
public enum Verb{
IS ("_is"),
LIE ("_lie");
LIE ("_lie"),
HANG("_hang");
String pathResource;
Verb(String pathResource){
......@@ -143,8 +144,9 @@ public abstract class AbstractObjectDescriptor {
return getVerbText(screen, NounType.PLURAL);
}
public static Verb getVerbByIndex(int index){
return values()[index];
public static Verb getVerb(int index, boolean wall){
return index == 0 ? IS : wall ? HANG : LIE;
}
}
......
/*
* Copyright (C) 2018 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.nic.tablexia.game.games.protocol.gameobjects.descriptors;
import java.util.Arrays;
import java.util.List;
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}));
private GameObjectType objectType;
private WallType wallOrientation;
private float[] rBRatio;
private float[] lBRatio;
private float[] rTRatio;
private float[] lTRatio;
private List<float[]> wallFixRatio;
WallObjectDescriptor(GameObjectType objectType, WallType wallOrientation, float[] lTRatio, float[]lBRatio, float[]rTRatio, float[] rBRatio, List<float[]> wallFixRatio){
this.objectType = objectType;
this.wallOrientation = wallOrientation;
this.rBRatio = rBRatio;
this.lBRatio = lBRatio;
this.rTRatio = rTRatio;
this.lTRatio = lTRatio;
this.wallFixRatio = wallFixRatio;
}
public static WallObjectDescriptor getDescriptorByType(GameObjectType objectType){
for (WallObjectDescriptor descriptor: values()){
if(descriptor.objectType == objectType)
return descriptor;
}
throw new RuntimeException("Couldn't get wall descriptor for object: " + objectType);
}
public WallType getWallOrientation() {
return wallOrientation;
}
public float[] getFixRatio(WallType wallType){
return wallFixRatio.get(wallType.getOriginType());
}
public float[] getrBRatio() {
return rBRatio;
}
public float[] getlBRatio() {
return lBRatio;
}
public float[] getrTRatio() {
return rTRatio;
}
public float[] getlTRatio() {
return lTRatio;
}
}
......@@ -36,21 +36,21 @@ import cz.nic.tablexia.game.games.protocol.gameobjects.wall.WallType;
public enum FurnitureType implements TypeObjectDescriptor {
//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_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_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_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_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_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_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, 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, 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, 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, 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, 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_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_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_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_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_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_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_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_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_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, 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, 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, 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, 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, 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, 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));
private static final int MEDIUM_RANGE_MIN = 0;
......@@ -63,16 +63,18 @@ public enum FurnitureType implements TypeObjectDescriptor {
private String textResource;
private GameDifficulty difficulty;
private RoomPosition mapPosition;
private WallType wallOrientation;
private float[] positionRation;
private float[] middleRatio;
private float[] fixPositionRatio;
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.textResource = textResource;
this.difficulty = difficulty;
this.mapPosition = mapPosition;
this.wallOrientation = wallOrientation;
this.positionRation = positionRatio;
this.middleRatio = middleRatio;
this.fixPositionRatio = fixPositionRatio;
......@@ -105,6 +107,10 @@ public enum FurnitureType implements TypeObjectDescriptor {
return fixPositionRatio;
}
public WallType getWallOrientation() {
return wallOrientation;
}
public static List<FurnitureType> getFurnitureTypesByDifficulty(GameDifficulty difficulty){
List<FurnitureType> types = new ArrayList<>();
for (FurnitureType type: values()){
......
......@@ -18,9 +18,8 @@
package cz.nic.tablexia.game.games.protocol.gameobjects.wall;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import cz.nic.tablexia.game.common.TablexiaRandom;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.protocol.gameobjects.GameObjectType;
import cz.nic.tablexia.game.games.protocol.gameobjects.TypeObjectDescriptor;
......@@ -29,19 +28,24 @@ import cz.nic.tablexia.game.games.protocol.gameobjects.TypeObjectDescriptor;
*/
public enum WallType implements TypeObjectDescriptor{
LEFT_WALL (new Color(0xff0000ff), new float[]{0.08f, 0.66f}, new float[]{0.3f, 0.82f}),
MIDDLE_WALL (new Color(0xff00ffff), new float[]{0.5f, 0.80f}, new float[]{0.5f, 0.82f}),
RIGHT_WALL (new Color(0x00ffffff), new float[]{0.92f, 0.65f}, new float[]{0.91f, 0.5f});
LEFT_WALL (new Color(0xff0000ff), new float[]{0.018f, 0.31f}, new float[]{0.354f, 0.586f}, new float[]{0.018f, 0.709f}, new float[]{0.353f, 0.98f}),
MIDDLE_WALL (new Color(0xff00ffff), new float[]{0.354f, 0.586f}, new float[]{0.65f, 0.586f}, new float[]{0.353f, 0.98f}, new float[]{0.65f, 0.98f}),
RIGHT_WALL (new Color(0x00ffffff), new float[]{0.65f, 0.586f}, new float[]{0.98f, 0.31f} , new float[]{0.65f, 0.98f}, new float[]{0.98f, 0.709f});
private Color wallColor;
private float[] fixMediumRatio;
private float[] fixHardRatio;
WallType(Color wallColor, float[] fixMediumRatio, float[] fixHardRatio){
private float[] lBRatio;
private float[] rBRatio;
private float[] lTRatio;
private float[] rTRatio;
WallType(Color wallColor, float[] lBRatio, float[] rBRatio, float[] lTRatio, float[] rTRatio){
this.wallColor = wallColor;
this.fixMediumRatio = fixMediumRatio;
this.fixHardRatio = fixHardRatio;
this.lBRatio = lBRatio;
this.rBRatio = rBRatio;
this.lTRatio = lTRatio;
this.rTRatio = rTRatio;
}
public static WallType getWallTypeByGameObjectType(GameObjectType objectType) {
......@@ -63,13 +67,25 @@ public enum WallType implements TypeObjectDescriptor{
return null;
}
public float[] getFixRatio(GameDifficulty difficulty) {
return difficulty == GameDifficulty.MEDIUM ? fixMediumRatio : fixHardRatio;
public Vector2 getlBPoint(float w, float h) {
return new Vector2(w * lBRatio[0], h * lBRatio[1]);
}
public Vector2 getrBPoint(float w, float h) {
return new Vector2(w * rBRatio[0], h * rBRatio[1]);
}
public Vector2 getlTPoint(float w, float h) {
return new Vector2(w * lTRatio[0], h * lTRatio[1]);
}
public Vector2 getrTPoint(float w, float h) {
return new Vector2(w * rTRatio[0], h * rTRatio[1]);
}
@Override
public int getOriginType() {
return ordinal();
}
}
......@@ -21,9 +21,11 @@ package cz.nic.tablexia.game.games.protocol.model.gameprotocol;
import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
......@@ -460,6 +462,7 @@ public abstract class ProtocolGenerator {
TextDescriptor textDescriptor = getTextDescriptor(protocolText);
Map<Sentence, Integer[]> sentenceMap = textDescriptor.getSentenceMap();
List<FurnitureType> furnitureTypes = FurnitureType.getFurnitureByDifficulty(difficulty);
List<WallType> wallTypes = new LinkedList<>(Arrays.asList(WallType.values()));
int sentenceCnt = 0;
startIndexVerb = random.nextInt(2);
......@@ -475,7 +478,7 @@ public abstract class ProtocolGenerator {
if (sentence.furnitureCnt != 0) {
typePositions = new ArrayList<>();
needAlternative = generateFurnitureForSentence(typePositions, furnitureTypes, textTypes, descriptorIndex, sentence.canBeMerge);
needAlternative = generateFurnitureForSentence(typePositions, furnitureTypes, wallTypes, textTypes, descriptorIndex, sentence.canBeMerge);
if (needAlternative) {
sentence = Sentence.getAlternativeSentence(sentence);
......@@ -507,7 +510,7 @@ public abstract class ProtocolGenerator {
return message;
}
private boolean generateFurnitureForSentence(List<TypeObjectDescriptor> typePositions, List<FurnitureType> furnitureTypes, TextType[] textTypes, Integer[] descriptorIndex, boolean canBeMerge) {
private boolean generateFurnitureForSentence(List<TypeObjectDescriptor> typePositions, List<FurnitureType> furnitureTypes, List<WallType> wallTypes, TextType[] textTypes, Integer[] descriptorIndex, boolean canBeMerge) {
for (int i = 0; i < textTypes.length; i++) {
if (textTypes[i] == TextType.Furniture_Wall) {
......@@ -533,17 +536,23 @@ public abstract class ProtocolGenerator {
controller.addPositionToSolution(objectType, Preposition.ON, furnitureType);
typePositions.add(furnitureType);
} else {
WallType wallType = WallType.getWallTypeByGameObjectType(objectType);
if(wallTypes == null || wallTypes.isEmpty())
wallTypes = Arrays.asList(WallType.values());
int rnd = random.nextInt(wallTypes.size());
WallType wallType = wallTypes.get(rnd);
controller.addPositionToSolution(objectType, Preposition.ON, wallType);
typePositions.add(wallType);
}
}
}
//Remove used furniture type
//Remove used furniture type and wall type
for (TypeObjectDescriptor position : typePositions) {
if (position instanceof FurnitureType && furnitureTypes.contains(position)) {
furnitureTypes.remove(position);
}else if (position instanceof WallType && wallTypes.contains(position)){
wallTypes.remove(position);
}
}
......@@ -586,7 +595,8 @@ public abstract class ProtocolGenerator {
texts[i] = preparePronoun(screen, descriptor);
break;
case Verb:
texts[i] = prepareVerb(screen, descriptor.getNounType(), startIndexVerb, alternative);
boolean wall = controller.isObjectOnWall(objectType);
texts[i] = prepareVerb(screen, descriptor.getNounType(), startIndexVerb, alternative, wall);
startIndexVerb = (startIndexVerb + 1) % 2;
break;
case Furniture_Wall:
......@@ -643,8 +653,8 @@ public abstract class ProtocolGenerator {
return descriptor.getPronounInflection(screen);
}
private String prepareVerb(AbstractTablexiaScreen screen, AbstractObjectDescriptor.NounType nounType, int startIndexVerb, boolean alternative) {
Verb verb = Verb.getVerbByIndex(startIndexVerb);
private String prepareVerb(AbstractTablexiaScreen screen, AbstractObjectDescriptor.NounType nounType, int startIndexVerb, boolean alternative, boolean wall) {
Verb verb = Verb.getVerb(startIndexVerb, wall);
return alternative ? verb.getPluralVerbText(screen) : verb.getVerbText(screen, nounType);
}
......
......@@ -40,6 +40,7 @@ import cz.nic.tablexia.game.games.protocol.controller.PositionPair;
import cz.nic.tablexia.game.games.protocol.gameobjects.GameObject;
import cz.nic.tablexia.game.games.protocol.gameobjects.GameObjectType;
import cz.nic.tablexia.game.games.protocol.gameobjects.TypeObjectDescriptor;
import cz.nic.tablexia.game.games.protocol.gameobjects.descriptors.WallObjectDescriptor;
import cz.nic.tablexia.game.games.protocol.gameobjects.furniture.Furniture;
import cz.nic.tablexia.game.games.protocol.gameobjects.furniture.FurnitureType;
import cz.nic.tablexia.game.games.protocol.gameobjects.wall.WallType;
......@@ -58,7 +59,6 @@ import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.shared.model.resolvers.ProtocolScoreResolver;
import cz.nic.tablexia.testing.games.AbstractTestGame;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ui.button.GameImageTablexiaButton;
import cz.nic.tablexia.util.ui.button.TablexiaButton;
......@@ -304,7 +304,8 @@ public class TestGameProtocol extends AbstractTestGame {
mistake();
}
float[] fixRatio = wallType.getFixRatio(difficulty);
WallObjectDescriptor descriptor = WallObjectDescriptor.getDescriptorByType(gameObject.getType());
float[] fixRatio = descriptor.getFixRatio(wallType);
float xPosition = roomGroup.getX() + roomGroup.getWidth() * fixRatio[0]/* - gameObject.getCenterPosition().x*/;
float yPosition = roomGroup.getY() + roomGroup.getHeight() * fixRatio[1]/* - gameObject.getCenterPosition().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