Commit 5a6f441b authored by Lukas Marik's avatar Lukas Marik

#945 prepare some protocol text for last round in bonus difficulty, minimim...

#945 prepare some protocol text for last round in bonus difficulty, minimim bounce far, repair behin control in outline efekt
parent c1a238ac
......@@ -649,6 +649,7 @@ public class ProtocolGame extends AbstractTablexiaGame<ProtocolGameState> {
public void addObjectForOutline(ObjectModel objectModel, boolean needUpdate){
Vector2 screenPosition = objectModel.getScreenPosition();
outLineGroup.addObject(
objectModel,
objectModel.getType(),
objectModel.getTexture(),
objectModel.getTypePosition(),
......
......@@ -52,7 +52,7 @@ import cz.nic.tablexia.util.Log;
public class RoomGroup extends Group {
public static final int MIN_OBJECTS_DISTANCE = 60;
public static final int MIN_OBJECTS_DISTANCE = 30;
private static final float WALL_PADDING = 10f;
private int countObjects = 0;
......
......@@ -94,7 +94,11 @@ public abstract class ProtocolGenerator {
TEXT_7_4(7, 3, true, new SentencePosition[]{SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FLOOR, SentencePosition.FURNITURE_WALL}),
TEXT_7_5(7, 2, true, new SentencePosition[]{SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FURNITURE_WALL} ),
TEXT_7_6(7, 1, true, new SentencePosition[]{SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL}),
TEXT_7_7(7, 0, true, new SentencePosition[]{SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL});
TEXT_7_7(7, 0, true, new SentencePosition[]{SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL}),
TEXT_8_1(8, 7, false, new SentencePosition[]{SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR}),
TEXT_8_2(8, 6, true, new SentencePosition[]{SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FURNITURE_WALL, SentencePosition.FLOOR, SentencePosition.FLOOR}),
TEXT_8_3(8, 5, true, new SentencePosition[]{SentencePosition.FURNITURE_WALL, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FURNITURE_WALL}),
TEXT_8_4(8, 4, true, new SentencePosition[]{SentencePosition.FURNITURE_WALL, SentencePosition.FURNITURE_WALL, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FLOOR, SentencePosition.FURNITURE_WALL});
private int objectsCount;
private int prepositionsCount;
......@@ -308,7 +312,33 @@ public abstract class ProtocolGenerator {
.put(Sentence.S2_FW_C_3_A, new Integer[]{0, 1, 0, 0})
.put(Sentence.A2_FW_C_1_A, new Integer[]{5, 5, 6, 5})
.put(Sentence.A2_FW_C_2_A, new Integer[]{3, 4, 3, 3})
.build());
.build()),
TEXT_8_1(4, ImmutableMap.<Sentence, Integer[]>builder()
.put(Sentence.S3_FL_C_1, new Integer[]{0, 0, 0, 1, 1, 1, 1, 2})
.put(Sentence.A2_FL_S_2, new Integer[]{3, 3, 3, 4})
.put(Sentence.A3_FL_C_1, new Integer[]{5, 5, 5, 2, 2, 2, 2, 6})
.put(Sentence.A3_FL_C_2, new Integer[]{7, 7, 7, 6, 6, 6, 6, 3})
.build()),
TEXT_8_2(4, ImmutableMap.<Sentence, Integer[]>builder()
.put(Sentence.S3_FL_C_2, new Integer[]{0, 0, 0, 1, 1, 1, 1, 2})
.put(Sentence.A3_FL_C_1, new Integer[]{3, 3, 3, 4, 4, 4, 4, 7})
.put(Sentence.A1_FW_S_1, new Integer[]{5, 5, 5})
.put(Sentence.A3_FL_C_2, new Integer[]{6, 6, 6, 2, 2, 2, 2, 7})
.build()),
TEXT_8_3(4, ImmutableMap.<Sentence, Integer[]>builder()
.put(Sentence.S4_FF_C_1, new Integer[]{0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3})
.put(Sentence.A2_FL_S_2, new Integer[]{4, 4, 4, 5})
.put(Sentence.A3_FL_C_1, new Integer[]{6, 6, 6, 5, 5, 5, 5, 1})
.put(Sentence.A1_FW_S_1, new Integer[]{7, 7, 7})
.build()),
/*TEXT_8_4(5, ImmutableMap.<Sentence, Integer[]>builder()
.put(Sentence.S2_FW_C_1, new Integer[]{0, 0, 0, 1, 1})
.put(Sentence.A2_FL_S_2, new Integer[]{2, 2, 2, 3})
.put(Sentence.A3_FL_C_1, new Integer[]{4, 4, 4, 5, 5, 5, 5, 6})
.put(Sentence.A2_FL_S_2, new Integer[]{6, 6, 6, 3})
.put(Sentence.A1_FW_S_2, new Integer[]{7, 7, 7})
.put(Sentence.S2_FW_C_1_A, new Integer[]{0, 0, 1, 0})
.build())*/;
private Map<Sentence , Integer[]> sentenceMap;
......
......@@ -31,7 +31,10 @@ import java.util.List;
import java.util.Map;
import java.util.Stack;
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.TypeObjectDescriptor;
import cz.nic.tablexia.game.games.protocol.gameobjects.furniture.FurnitureType;
import cz.nic.tablexia.util.Log;
......@@ -84,11 +87,11 @@ public class OutLineGroup extends Group {
Rectangle controlRect = controlDescriptor.getObjectRect();
if (updateDescriptor.getTypePosition() != control) {
if (checkCollision(updateRect, controlRect) && controlDescriptor.getyMiddlePosition() < updateDescriptor.getyMiddlePosition()) {
if (isBehindRendered(updateObject,controlObject) && checkCollision(updateRect, controlRect)) {
addTypeToMap(update);
addActor(updateObject);
collision = true;
} else if (checkCollision(controlRect, updateRect) && controlDescriptor.getyMiddlePosition() > updateDescriptor.getyMiddlePosition()) {
} else if (isBehindRendered(controlObject, updateObject) && checkCollision(controlRect, updateRect)) {
addTypeToMap(control);
addActor(controlObject);
}
......@@ -105,24 +108,38 @@ public class OutLineGroup extends Group {
}
private boolean checkCollision(Rectangle first, Rectangle second) {
if (computeArea(first.getWidth(), first.getHeight()) > computeArea(second.getWidth(), second.getHeight()) || !first.overlaps(second))
private boolean checkCollision(Rectangle firstR, Rectangle secondR) {
if (computeArea(firstR.getWidth(), firstR.getHeight()) > computeArea(secondR.getWidth(), secondR.getHeight()) || !firstR.overlaps(secondR))
return false;
float xOver = Math.max(first.getX(), second.getX());
float yOver = Math.max(first.getY(), second.getY());
float xOver = Math.max(firstR.getX(), secondR.getX());
float yOver = Math.max(firstR.getY(), secondR.getY());
float wOver = Math.min(first.getX() + first.getWidth(), second.getX() + second.getWidth());
float hOver = Math.min(first.getY() + first.getHeight(), second.getY() + second.getHeight());
float wOver = Math.min(firstR.getX() + firstR.getWidth(), secondR.getX() + secondR.getWidth());
float hOver = Math.min(firstR.getY() + firstR.getHeight(), secondR.getY() + secondR.getHeight());
float diffArea = computeArea(wOver - xOver, hOver - yOver);
float control = computeArea(first.getWidth(), first.getHeight());
float control = computeArea(firstR.getWidth(), firstR.getHeight());
float percentOver = (diffArea * 100 / control);
return percentOver >= OVER_PERCENT;
}
private boolean isBehindRendered(OutLineObject first, OutLineObject second){
if(first.getOutLineObjectType() == OutLineObject.OutLineObjectType.GAMEOBJECT){
GameObject firstObject = (GameObject) first.getParent();
if(firstObject.getRoomPosition() == RoomPosition.FURNITURE && second.getParent().getRoomPosition() != RoomPosition.FURNITURE)
return firstObject.getFurniture().getZIndex() < second.getParent().getZIndex();
}
return first.getParent().getZIndex() < second.getParent().getZIndex();
}
private float computeArea(float w, float h) {
return w * h;
}
......@@ -138,8 +155,9 @@ public class OutLineGroup extends Group {
shaderProgram.dispose();
}
public void addObject(TypeObjectDescriptor type, TextureRegion textureRegion, TypeObjectDescriptor typePosition, float xPosition, float yPosition, float width, float height, float yMiddlePosition) {
public void addObject(ObjectModel objectModel, TypeObjectDescriptor type, TextureRegion textureRegion, TypeObjectDescriptor typePosition, float xPosition, float yPosition, float width, float height, float yMiddlePosition) {
if (!objectScreenPosition.containsKey(type)) {
OutLineObject.OutLineObjectType outLineObjectType = type instanceof GameObjectType ? OutLineObject.OutLineObjectType.GAMEOBJECT : OutLineObject.OutLineObjectType.FURNITURE;
OutlineObjectDescriptor descriptor = new OutlineObjectDescriptor(
textureRegion,
new Vector2(xPosition, yPosition),
......@@ -149,12 +167,12 @@ public class OutLineGroup extends Group {
yMiddlePosition,
getRectDescriptor(type),
(type instanceof GameObjectType));
objectScreenPosition.put(type, new OutLineObject(descriptor, shaderProgram));
objectScreenPosition.put(type, new OutLineObject(outLineObjectType, objectModel, descriptor, shaderProgram));
} else {
objectScreenPosition.get(type).getDescriptor().updateData(new Vector2(xPosition, yPosition), typePosition, yMiddlePosition);
}
if (type instanceof GameObjectType) {
if (objectScreenPosition.get(type).getOutLineObjectType() == OutLineObject.OutLineObjectType.GAMEOBJECT) {
updatedStack.add(type);
}
}
......
......@@ -22,18 +22,28 @@ import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Group;
import cz.nic.tablexia.game.games.protocol.gameobjects.ObjectModel;
/**
* Created by lmarik on 12.3.18.
*/
public class OutLineObject extends Group {
public enum OutLineObjectType{
FURNITURE, GAMEOBJECT
}
private OutLineObjectType outLineObjectType;
private ObjectModel parent;
private OutlineObjectDescriptor descriptor;
private ShaderProgram shaderProgram;
private float atlasWidth;
private float atlasHeight;
public OutLineObject(OutlineObjectDescriptor descriptor, ShaderProgram shaderProgram) {
public OutLineObject(OutLineObjectType outLineObjectType,ObjectModel parent,OutlineObjectDescriptor descriptor, ShaderProgram shaderProgram) {
this.outLineObjectType = outLineObjectType;
this.parent = parent;
this.descriptor = descriptor;
this.shaderProgram = shaderProgram;
......@@ -63,6 +73,15 @@ public class OutLineObject extends Group {
batch.begin();
}
@Override
public ObjectModel getParent() {
return parent;
}
public OutLineObjectType getOutLineObjectType() {
return outLineObjectType;
}
public OutlineObjectDescriptor getDescriptor() {
return descriptor;
}
......
......@@ -163,6 +163,9 @@ public class ProtocolDragListener extends DragActorListener {
@Override
public void run() {
protocolGame.resetDragLayoutObject();
if(gameObject.isInRoom())
protocolGame.addObjectForOutline(gameObject, true);
}
});
}
......
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