Commit 0c499a3b authored by Lukas Marik's avatar Lukas Marik

#945 set edgepoints for object and wall in bonus difficulty, repair redraw...

#945 set edgepoints for object and wall in bonus difficulty, repair redraw outline effect on wall after bounce
parent 68911c6c
......@@ -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.EdgePoints;
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;
......@@ -150,7 +151,8 @@ public class GameObject extends ObjectModel {
}
private void changePointsPosition(){
//TODO opravit put point pri rotaci obrazu
/*private void changePointsPosition(){
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
......@@ -166,18 +168,19 @@ public class GameObject extends ObjectModel {
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();
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]));
EdgePoints edgePoints = descriptor.getEdgePoints();
rBPoint = new Vector2(minWidth * (rotate ? (1.f - edgePoints.getlBRatio()[0]) : edgePoints.getrBRatio()[0]), minHeight * (rotate ? edgePoints.getlBRatio()[1] : edgePoints.getrBRatio()[1]));
rTPoint = new Vector2(minWidth * (rotate ? (1.f - edgePoints.getlTRatio()[0]) : edgePoints.getrTRatio()[0]), minHeight * (rotate ? edgePoints.getlTRatio()[1] : edgePoints.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]));
lBPoint = new Vector2(minWidth * (rotate ? (1.f - edgePoints.getrBRatio()[0]) : edgePoints.getlBRatio()[0]), minHeight * (rotate ? edgePoints.getrBRatio()[1] : edgePoints.getlBRatio()[1]));
lTPoint = new Vector2(minWidth * (rotate ? (1.f - edgePoints.getrTRatio()[0]) : edgePoints.getlTRatio()[0]), minHeight * (rotate ? edgePoints.getrTRatio()[1] : edgePoints.getlTRatio()[1]));
}else {
float topRatio = 0.97f;
float bottomRatio = 0.04f;
......@@ -304,7 +307,7 @@ public class GameObject extends ObjectModel {
public void rotateObject(boolean rotate){
this.rotate = rotate;
objectDrawable.flip(rotate ^ objectDrawable.isFlipX(), false);
changePointsPosition();
//changePointsPosition();
if(canPutOnPosition(RoomPosition.WALL))
initEdgePoint(WallObjectDescriptor.getDescriptorByType(type));
......
/*
* 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 com.badlogic.gdx.math.Vector2;
public class EdgePoints {
private float[] lTRatio;
private float[] lBRatio;
private float[] rTRatio;
private float[] rBRatio;
public EdgePoints(float[] lTRatio, float[] lBRatio, float[] rTRatio, float[] rBRatio){
this.lTRatio = lTRatio;
this.lBRatio = lBRatio;
this.rTRatio = rTRatio;
this.rBRatio = rBRatio;
}
public float[] getlTRatio() {
return lTRatio;
}
public float[] getlBRatio() {
return lBRatio;
}
public float[] getrTRatio() {
return rTRatio;
}
public float[] getrBRatio() {
return rBRatio;
}
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]);
}
}
......@@ -24,33 +24,30 @@ 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})),
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}));
//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})),
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}));
private GameObjectType objectType;
private WallType wallOrientation;
private float[] rBRatio;
private float[] lBRatio;
private float[] rTRatio;
private float[] lTRatio;
private EdgePoints edgePoints;
private List<float[]> wallFixRatio;
WallObjectDescriptor(GameObjectType objectType, WallType wallOrientation, float[] lTRatio, float[]lBRatio, float[]rTRatio, float[] rBRatio, List<float[]> wallFixRatio){
WallObjectDescriptor(GameObjectType objectType, WallType wallOrientation, EdgePoints edgePoints, List<float[]> wallFixRatio){
this.objectType = objectType;
this.wallOrientation = wallOrientation;
this.edgePoints = edgePoints;
this.rBRatio = rBRatio;
this.lBRatio = lBRatio;
this.rTRatio = rTRatio;
this.lTRatio = lTRatio;
this.wallFixRatio = wallFixRatio;
}
......@@ -74,19 +71,7 @@ public enum WallObjectDescriptor {
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;
public EdgePoints getEdgePoints() {
return edgePoints;
}
}
......@@ -18,44 +18,43 @@
package cz.nic.tablexia.game.games.protocol.gameobjects.wall;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.google.common.collect.ImmutableMap;
import cz.nic.tablexia.game.games.protocol.gameobjects.GameObjectType;
import java.util.Map;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.protocol.gameobjects.TypeObjectDescriptor;
import cz.nic.tablexia.game.games.protocol.gameobjects.descriptors.EdgePoints;
/**
* Created by lmarik on 18.8.17.
*/
public enum WallType implements TypeObjectDescriptor{
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});
LEFT_WALL (new Color(0xff0000ff),
ImmutableMap.<GameDifficulty, EdgePoints>builder()
.put(GameDifficulty.MEDIUM, new EdgePoints(new float[]{0.018f, 0.709f}, new float[]{0.018f, 0.31f},new float[]{0.353f, 0.98f}, new float[]{0.354f, 0.586f}))
.put(GameDifficulty.BONUS, new EdgePoints(new float[]{0.018f, 0.709f}, new float[]{0.018f, 0.49f},new float[]{0.353f, 0.98f}, new float[]{0.354f, 0.775f}))
.build()),
MIDDLE_WALL (new Color(0xff00ffff),
ImmutableMap.<GameDifficulty, EdgePoints>builder()
.put(GameDifficulty.MEDIUM, new EdgePoints(new float[]{0.353f, 0.98f}, new float[]{0.354f, 0.586f}, new float[]{0.65f, 0.98f}, new float[]{0.65f, 0.586f}))
.put(GameDifficulty.BONUS, new EdgePoints(new float[]{0.353f, 0.98f}, new float[]{0.354f, 0.775f}, new float[]{0.65f, 0.98f}, new float[]{0.65f, 0.775f}))
.build()),
RIGHT_WALL (new Color(0x00ffffff),
ImmutableMap.<GameDifficulty, EdgePoints>builder()
.put(GameDifficulty.MEDIUM, new EdgePoints(new float[]{0.65f, 0.98f}, new float[]{0.65f, 0.586f}, new float[]{0.98f, 0.709f}, new float[]{0.98f, 0.31f}))
.put(GameDifficulty.BONUS, new EdgePoints(new float[]{0.65f, 0.98f}, new float[]{0.65f, 0.775f}, new float[]{0.98f, 0.709f}, new float[]{0.98f, 0.49f}))
.build());
private Color wallColor;
private float[] lBRatio;
private float[] rBRatio;
private float[] lTRatio;
private float[] rTRatio;
private Map<GameDifficulty, EdgePoints> edgePointsMap;
WallType(Color wallColor, float[] lBRatio, float[] rBRatio, float[] lTRatio, float[] rTRatio){
WallType(Color wallColor, Map<GameDifficulty, EdgePoints> edgePointsMap){
this.wallColor = wallColor;
this.lBRatio = lBRatio;
this.rBRatio = rBRatio;
this.lTRatio = lTRatio;
this.rTRatio = rTRatio;
}
public static WallType getWallTypeByGameObjectType(GameObjectType objectType) {
if (objectType == GameObjectType.LADY_AND_PANDA || objectType == GameObjectType.CUCKOO_CLOCK)
return LEFT_WALL;
else if (objectType == GameObjectType.LANDSCAPE || objectType == GameObjectType.MIRROR)
return RIGHT_WALL;
return null;
this.edgePointsMap = edgePointsMap;
}
public static WallType getWallTypeByColor(Color color){
......@@ -67,20 +66,8 @@ public enum WallType implements TypeObjectDescriptor{
return null;
}
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]);
public EdgePoints getEdgePointsByDifficulty(GameDifficulty difficulty){
return edgePointsMap.get(difficulty);
}
@Override
......
......@@ -36,6 +36,7 @@ import cz.nic.tablexia.game.games.protocol.controller.RoomPosition;
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.EdgePoints;
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;
......@@ -308,10 +309,11 @@ public class RoomGroup extends Group {
float roomWidth = getWidth();
float roomHeight = getHeight();
Vector2 lBWall = wallType.getlBPoint(roomWidth, roomHeight);
Vector2 lTWall = wallType.getlTPoint(roomWidth, roomHeight);
Vector2 rBWall = wallType.getrBPoint(roomWidth, roomHeight);
Vector2 rTWall = wallType.getrTPoint(roomWidth, roomHeight);
EdgePoints wallEdgePoints = wallType.getEdgePointsByDifficulty(protocolGame.getGameDifficulty());
Vector2 lBWall = wallEdgePoints.getlBPoint(roomWidth, roomHeight);
Vector2 lTWall = wallEdgePoints.getlTPoint(roomWidth, roomHeight);
Vector2 rBWall = wallEdgePoints.getrBPoint(roomWidth, roomHeight);
Vector2 rTWall = wallEdgePoints.getrTPoint(roomWidth, roomHeight);
boolean checkLBPoints = checkPointBetweenTwoLines(rBWall, lBWall, lTWall, lBObject);
boolean checkLTPoints = checkPointBetweenTwoLines(rTWall, lTWall, lBWall, lTObject);
......@@ -337,7 +339,12 @@ public class RoomGroup extends Group {
float correctX = gameObject.getX() + (wall.x - object.x) + WALL_PADDING * ((useRT || useRB) ? -1 : 1);
float correctY = gameObject.getY() + (wall.y - object.y) + WALL_PADDING * ((useLT || useRT) ? -1 : 1);
gameObject.moveToPosition(true, correctX, correctY, null);
gameObject.moveToPosition(true, correctX, correctY, new Runnable() {
@Override
public void run() {
changeOutlinePosition(gameObject);
}
});
} else if (pointsCNT == 2) {
boolean bottom = checkLTPoints && checkRTPoints;
......@@ -388,7 +395,12 @@ public class RoomGroup extends Group {
float correctX = gameObject.getX() - (check.x - intersect.x) + paddingX;
float correctY = gameObject.getY() - (check.y - intersect.y) + paddingY;
gameObject.moveToPosition(true, correctX, correctY, null);
gameObject.moveToPosition(true, correctX, correctY, new Runnable() {
@Override
public void run() {
changeOutlinePosition(gameObject);
}
});
}
}
......@@ -515,7 +527,7 @@ public class RoomGroup extends Group {
setZIndexForList(objectOnTheFloor, zIndex);
if(bounceObjectType == null || bounceObjectType != controlled.getType()){
if(!controlled.hasActions() && (bounceObjectType == null || bounceObjectType != controlled.getType())){
changeOutlinePosition(controlled);
}
......
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