canFall in Worm en Facade
This commit is contained in:
@@ -120,7 +120,7 @@ public class Facade implements IFacade {
|
||||
*/
|
||||
@Override
|
||||
public boolean canFall(Worm worm) throws MustNotImplementException {
|
||||
return false;
|
||||
return worm.canFall();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -832,14 +832,14 @@ public class Worm extends GameObject {
|
||||
double[] center = {getLocation().getX(), getLocation().getY()};
|
||||
Coordinate oldLocation = getLocation();
|
||||
double endY = getLocation().getY();
|
||||
if (! getWorld().isAdjacent(center, minRadius)) {
|
||||
if (canFall()) {
|
||||
for (double y = oldLocation.getY(); y <= (getWorld().getHeight() + 1); y--) {
|
||||
if (y >= (getWorld().getHeight() + 1)) {
|
||||
terminate();
|
||||
}
|
||||
double[] newLoc = {oldLocation.getX(), y};
|
||||
setLocation(newLoc);
|
||||
if (getWorld().isAdjacent(center, minRadius)) {
|
||||
if (! canFall()) {
|
||||
endY = y;
|
||||
break;
|
||||
}
|
||||
@@ -851,6 +851,11 @@ public class Worm extends GameObject {
|
||||
decreaseHitPoints(cost);
|
||||
}
|
||||
|
||||
public boolean canFall() {
|
||||
double[] center = {getLocation().getX(), getLocation().getY()};
|
||||
return ! getWorld().isAdjacent(center, minRadius);
|
||||
}
|
||||
|
||||
public void collisionFall(Worm fallingWorm, Worm... worm) {
|
||||
for (Worm stationaryWorm: worm) {
|
||||
long value = stationaryWorm.getHitPoints()/2;
|
||||
|
Reference in New Issue
Block a user