Commit b40ee387 authored by Vitaliy Vashchenko's avatar Vitaliy Vashchenko

Merge branch 'feature-protocol-bonus' into 'V3.7'

#945 Feature protocol bonus

See merge request !740
parents a6146fa0 f5c9e422
......@@ -76,7 +76,7 @@ public class ObjectsController {
}
public boolean isObjectOnWall(GameObjectType objectType){
return objectsOnWall.contains(objectType);
return objectsOnWall.contains(objectType) || objectType == GameObjectType.KIMONO;
}
//////////////////////////// OBJECTS CONTROL
......
......@@ -27,7 +27,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
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;
......@@ -69,9 +68,6 @@ public class GameObject extends ObjectModel {
private static final float LABEL_WITH_RATIO = 0.95f;
private static final float LABEL_PADDING_BOTTOM = 18f;
private static final float DEFAULT_SCALE_NONE = 1f;
private static final float DEFAULT_SCALE_DESKTOP_HD = 0.45f;
private boolean biggerScale = false;
private boolean inRoom = false;
......@@ -106,6 +102,7 @@ public class GameObject extends ObjectModel {
private boolean middle;
public GameObject(GameObjectType type, ProtocolGame protocolGame, String cardText, boolean inPicture) {
super();
this.type = type;
this.inRoom = inPicture;
this.cardText = cardText;
......@@ -129,8 +126,8 @@ public class GameObject extends ObjectModel {
//////////////////////////// INITIALIZATION
public void initPoints(){
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
float minWidth = getMinWidth();
float minHeight = getMinHeight();
float xCenter = minWidth * type.getCenterRatio()[0];
float yCenter = minHeight * type.getCenterRatio()[1];
......@@ -155,8 +152,8 @@ public class GameObject extends ObjectModel {
if(type.getWallRatio() == null)
return;
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
float minWidth = getMinWidth();
float minHeight = getMinHeight();
if(!middle) {
wallPoint.x = minWidth * (rotate ? (1f - type.getWallRatio()[0]) : type.getWallRatio()[0]);
......@@ -170,8 +167,8 @@ public class GameObject extends ObjectModel {
private void initEdgePoint(WallObjectDescriptor descriptor){
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
float minWidth = getMinWidth();
float minHeight = getMinHeight();
if(!middle) {
EdgePoints edgePoints = descriptor.getEdgePoints();
......@@ -228,8 +225,7 @@ public class GameObject extends ObjectModel {
private void changeSize() {
if (isInRoom()) {
float scaleFactor = TablexiaSettings.getInstance().isUseHdAssets() ? DEFAULT_SCALE_DESKTOP_HD : DEFAULT_SCALE_NONE;
objectImage.setSize(objectImage.getDrawable().getMinWidth() * scaleFactor, objectImage.getDrawable().getMinHeight() * scaleFactor);
objectImage.setSize(getMinWidth(), getMinHeight());
} else
objectImage.setSize(ProtocolGame.CARD_SMALL_SIZE, ProtocolGame.CARD_SMALL_SIZE);
}
......@@ -514,14 +510,22 @@ public class GameObject extends ObjectModel {
return new Vector2(getX() + furniturePosition.x,getY() + furniturePosition.y);
}
public float getMinWidth(){
return objectImage.getDrawable().getMinWidth() * scaleFactor;
}
public float getMinHeight(){
return objectImage.getDrawable().getMinHeight() * scaleFactor;
}
@Override
public float getImageWidth() {
return objectDrawable.getRegionWidth();
return objectDrawable.getRegionWidth() * scaleFactor;
}
@Override
public float getImageHeight() {
return objectDrawable.getRegionHeight();
return objectDrawable.getRegionHeight() * scaleFactor;
}
@Override
......
......@@ -23,6 +23,7 @@ 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.TablexiaSettings;
import cz.nic.tablexia.game.games.protocol.controller.RoomPosition;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
......@@ -31,6 +32,9 @@ import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
*/
public abstract class ObjectModel extends Group {
protected static final float DEFAULT_SCALE_NONE = 1f;
protected static final float DEFAULT_SCALE_DESKTOP_HD = 0.45f;
public abstract TypeObjectDescriptor getType();
public abstract TextureRegion getTexture();
public abstract float getImageWidth();
......@@ -41,7 +45,11 @@ public abstract class ObjectModel extends Group {
protected Vector2 putPoint; //check furniture position
protected Vector2 wallPoint; //check wall position
protected RoomPosition roomPosition;
protected float scaleFactor;
public ObjectModel(){
scaleFactor = TablexiaSettings.getInstance().isUseHdAssets() ? DEFAULT_SCALE_DESKTOP_HD : DEFAULT_SCALE_NONE;
}
public Vector2 getCenterScreenPosition() {
return new Vector2(getX() + centerPosition.x, getY() + centerPosition.y);
......@@ -96,6 +104,10 @@ public abstract class ObjectModel extends Group {
this.roomPosition = roomPosition;
}
public float getScaleFactor() {
return scaleFactor;
}
public void zIndexChanged(){
}
......
......@@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.game.games.protocol.controller.RoomPosition;
import cz.nic.tablexia.game.games.protocol.gameobjects.ObjectModel;
import cz.nic.tablexia.game.games.protocol.utils.ObjectsPositionComparator;
......@@ -43,17 +42,13 @@ public class Furniture extends ObjectModel {
private List<ObjectModel> objectOnFurniture;
private static final float DEFAULT_SCALE_NONE = 1f;
private static final float DEFAULT_SCALE_DESKTOP_HD = 0.45f;
public Furniture(FurnitureType type, TextureRegion texture, float resizePercent) {
super();
this.type = type;
this.texture = texture;
furnitureImage = new Image(texture);
float scaleFactor = TablexiaSettings.getInstance().isUseHdAssets() ? DEFAULT_SCALE_DESKTOP_HD : DEFAULT_SCALE_NONE;
furnitureImage.setWidth((furnitureImage.getDrawable().getMinWidth() * resizePercent * scaleFactor) / 100);
furnitureImage.setHeight((furnitureImage.getDrawable().getMinHeight() * resizePercent * scaleFactor) / 100);
......
......@@ -47,8 +47,8 @@ public class OutLineObject extends Group {
this.descriptor = descriptor;
this.shaderProgram = shaderProgram;
atlasWidth = descriptor.getTextureRegion().getTexture().getWidth();
atlasHeight = descriptor.getTextureRegion().getTexture().getHeight();
atlasWidth = descriptor.getTextureRegion().getTexture().getWidth() * parent.getScaleFactor();
atlasHeight = descriptor.getTextureRegion().getTexture().getHeight()* parent.getScaleFactor();
}
......@@ -66,7 +66,7 @@ public class OutLineObject extends Group {
batch.setShader(shaderProgram);
batch.begin();
batch.draw(descriptor.getTextureRegion(), getX() + descriptor.getScreenPosition().x, getY() + descriptor.getScreenPosition().y);
batch.draw(descriptor.getTextureRegion(), getX() + descriptor.getScreenPosition().x, getY() + descriptor.getScreenPosition().y, parent.getImageWidth(), parent.getImageHeight());
batch.end();
batch.setShader(null);
......
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