Commit 43b6a21e authored by Lukas Marik's avatar Lukas Marik

#940 simplytify rotate

parent d2a63cef
......@@ -145,15 +145,31 @@ public class GameObject extends ObjectModel {
if(wallRatio != null){
wallPoint = new Vector2(minWidth * wallRatio[0], minHeight * wallRatio[1]);
initEdgePoint(WallObjectDescriptor.getDescriptorByType(type));
}
}
public void initEdgePoint(WallObjectDescriptor descriptor){
float minWidth = objectImage.getDrawable().getMinWidth();
float minHeight = objectImage.getDrawable().getMinHeight();
WallObjectDescriptor descriptor = WallObjectDescriptor.getDescriptorByType(type);
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]));
rBPoint = new Vector2(minWidth * descriptor.getrBRatio()[0], minHeight * descriptor.getrBRatio()[1]);
rTPoint = new Vector2(minWidth * descriptor.getrTRatio()[0], minHeight * 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 * descriptor.getlBRatio()[0], minHeight * descriptor.getlBRatio()[1]);
lTPoint = new Vector2(minWidth * descriptor.getlTRatio()[0], minHeight * descriptor.getlTRatio()[1]);
lBPoint = new Vector2(minWidth * bottomRatio, minHeight * bottomRatio);
lTPoint = new Vector2(minWidth * bottomRatio, minHeight * topRatio);
}
}
public void initDragListener() {
......@@ -265,11 +281,10 @@ public class GameObject extends ObjectModel {
return type.checkPosition(position);
}
public void rotateObject(boolean rotateX){
if(rotateX) {
rotate = !rotate;
}
objectDrawable.flip(rotateX, false);
public void rotateObject(boolean rotate){
this.rotate = rotate;
objectDrawable.flip(rotate ^ objectDrawable.isFlipX(), false);
initEdgePoint(WallObjectDescriptor.getDescriptorByType(type));
}
public void middleTexture(boolean useMiddleTexture){
......@@ -280,9 +295,6 @@ public class GameObject extends ObjectModel {
objectImage.setDrawable(new TextureRegionDrawable(objectDrawable));
changeSize();
this.middle = useMiddleTexture;
if(useMiddleTexture)
rotate = false;
}
......
......@@ -159,7 +159,7 @@ public class RoomGroup extends Group {
gameObject.setRoomPosition(null);
gameObject.setWallPositionType(null);
gameObject.middleTexture(false);
gameObject.rotateObject(gameObject.isRotate());
gameObject.rotateObject(false);
}
public void resetData() {
......@@ -265,9 +265,8 @@ public class RoomGroup extends Group {
if((position == RoomPosition.WALL || previousPosition == RoomPosition.WALL) && wallType != changedObject.getWallPositionType()) {
WallObjectDescriptor descriptor = WallObjectDescriptor.getDescriptorByType(changedObject.getType());
boolean isRotate = changedObject.isRotate();
changedObject.middleTexture(wallType == WallType.MIDDLE_WALL);
changedObject.rotateObject(position != RoomPosition.WALL ? isRotate : isRotate ^ (descriptor.getWallOrientation() != wallType && wallType != WallType.MIDDLE_WALL));
changedObject.rotateObject((position == RoomPosition.WALL) && (descriptor.getWallOrientation() != wallType && wallType != WallType.MIDDLE_WALL));
}
if(position == RoomPosition.WALL)
......
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