Fix block shooting state
This commit is contained in:
parent
5e5aeb31e2
commit
6c84c8727b
@ -53,8 +53,7 @@ public class Turret implements Constants {
|
|||||||
shootInfo.draw(g);
|
shootInfo.draw(g);
|
||||||
if (shootInfo.isOver()) {
|
if (shootInfo.isOver()) {
|
||||||
shootState = false;
|
shootState = false;
|
||||||
}
|
} else if (shootInfo.isCollideTerrain(terrain)) {
|
||||||
if (shootInfo.isCollideTerrain(terrain)) {
|
|
||||||
shootState = false;
|
shootState = false;
|
||||||
terrain.destroyTerrain((int) shootInfo.x);
|
terrain.destroyTerrain((int) shootInfo.x);
|
||||||
}
|
}
|
||||||
@ -85,6 +84,8 @@ public class Turret implements Constants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBarrelParams(int x, int y) {
|
public void setBarrelParams(int x, int y) {
|
||||||
|
if (shootState) return;
|
||||||
|
|
||||||
double angle = Math.atan2(y - turretY, x - turretX);
|
double angle = Math.atan2(y - turretY, x - turretX);
|
||||||
if (!server) angle = Math.PI - angle;
|
if (!server) angle = Math.PI - angle;
|
||||||
if ( (0d <= angle) && (angle <= ANGLE_90) ) {
|
if ( (0d <= angle) && (angle <= ANGLE_90) ) {
|
||||||
@ -96,6 +97,8 @@ public class Turret implements Constants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shoot() {
|
public void shoot() {
|
||||||
|
if (shootState) return;
|
||||||
|
|
||||||
shootState = true;
|
shootState = true;
|
||||||
shootInfo.reset();
|
shootInfo.reset();
|
||||||
shootInfo.x = barrelX;
|
shootInfo.x = barrelX;
|
||||||
|
Loading…
Reference in New Issue
Block a user