fire bijwerken

This commit is contained in:
Leen Dereu
2018-05-20 14:22:47 +02:00
parent 72cd481583
commit 6313adaf4c

View File

@@ -7,6 +7,7 @@ import worms.util.IllegalNameException;
import static java.lang.Math.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
@@ -1217,6 +1218,16 @@ public class Worm extends GameObject {
//TODO location overlaps with 1 or more projectiles => firing worm is hit by one overlapping projectile
//TODO => method returns null
if (! getWorld().getGameObjectsByClass(Projectile.class).isEmpty()) {
List<Projectile> projectiles = getWorld().getGameObjectsByClass(Projectile.class);
for (Projectile project: projectiles) {
if (this.getDistance(project) <= 0) {
project.hit(this);
return null;
}
}
}
int random = ThreadLocalRandom.current().nextInt(2);