|
|
|
|
@ -20,7 +20,7 @@ public class FightScreen {
|
|
|
|
|
|
|
|
|
|
Vector2 gridPos;
|
|
|
|
|
|
|
|
|
|
// 0: player turn, 1: enemy turn, 2: fight ends
|
|
|
|
|
// 0: positioning all Objects on the grid 1: player turn, 2: enemy turn, 3: fight ends
|
|
|
|
|
int state = 0;
|
|
|
|
|
|
|
|
|
|
public FightScreen(Batch batch, FightObject[] objects, Rectangle[] collisionRects, float camX, float camY) {
|
|
|
|
|
@ -34,9 +34,8 @@ public class FightScreen {
|
|
|
|
|
gridPos.x = (float)(Math.ceil((double)(camX-Main.CAMERA_WIDTH/2)/32.0) * 32.0) + 64;
|
|
|
|
|
gridPos.y = (float)(Math.ceil((double)(camY-Main.CAMERA_HEIGHT/2)/32.0) * 32.0) + 32;
|
|
|
|
|
|
|
|
|
|
// gridPos.x = camX-Main.CAMERA_WIDTH/2;
|
|
|
|
|
// gridPos.y = camY-Main.CAMERA_HEIGHT/2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SORTING OBJECTS BY INITIATIVE STAT
|
|
|
|
|
/*
|
|
|
|
|
for(int j = 0; j < objects.length-1; j++){
|
|
|
|
|
for(int i = objects.length-1; i >= 0; i--){
|
|
|
|
|
@ -46,11 +45,57 @@ public class FightScreen {
|
|
|
|
|
objects[i] = temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void act(float deltatime) {
|
|
|
|
|
|
|
|
|
|
if(state == 0){
|
|
|
|
|
boolean finished = true;
|
|
|
|
|
for(FightObject object : objects){
|
|
|
|
|
Vector2 POI = new Vector2((int)(Math.ceil((double)(object.x)/32.0) * 32.0) - 16, (int)(Math.ceil((double)(object.y)/32.0) * 32.0));
|
|
|
|
|
Vector2 movement = new Vector2(3,0);
|
|
|
|
|
movement.setAngleRad(StaticMath.calculateAngle(object.x, object.y, POI.x, POI.y));
|
|
|
|
|
int facing;
|
|
|
|
|
if(movement.angleDeg() < 135 && movement.angleDeg() >= 45) {
|
|
|
|
|
facing = 0;
|
|
|
|
|
}
|
|
|
|
|
else if(movement.angleDeg() >= 135 && movement.angleDeg() < 225) {
|
|
|
|
|
facing = 1;
|
|
|
|
|
}
|
|
|
|
|
else if(movement.angleDeg() >= 225 && movement.angleDeg() < 315) {
|
|
|
|
|
facing = 2;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
facing = 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(StaticMath.calculateDistance(object.x, object.y, POI.x, POI.y, movement.angleRad()) < 1f) {
|
|
|
|
|
movement.x = 0;
|
|
|
|
|
movement.y = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object.setX(object.x + movement.x);
|
|
|
|
|
object.setY(object.y + movement.y);
|
|
|
|
|
|
|
|
|
|
int animationRow = 0;
|
|
|
|
|
if(movement.x != 0 || movement.y != 0) {
|
|
|
|
|
animationRow = 8;
|
|
|
|
|
}
|
|
|
|
|
object.sprite.setRow(animationRow + facing);
|
|
|
|
|
|
|
|
|
|
if(movement.x != 0 || movement.y != 0){
|
|
|
|
|
finished = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(finished){
|
|
|
|
|
state = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(FightObject object : objects) {
|
|
|
|
|
object.sprite.updateAnimation(deltatime);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void draw() {
|
|
|
|
|
@ -74,11 +119,11 @@ public class FightScreen {
|
|
|
|
|
Gdx.gl.glDisable(GL20.GL_BLEND);
|
|
|
|
|
|
|
|
|
|
batch.begin();
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
for(FightObject object : objects) {
|
|
|
|
|
object.sprite.draw(batch);
|
|
|
|
|
object.sprite.draw(batch);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
batch.end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|