diff --git a/OGP1718-Worms/src/worms/model/Projectile.java b/OGP1718-Worms/src/worms/model/Projectile.java index 412c49e..79bf361 100644 --- a/OGP1718-Worms/src/worms/model/Projectile.java +++ b/OGP1718-Worms/src/worms/model/Projectile.java @@ -27,4 +27,6 @@ public class Projectile extends GameObject { public void setForce(double force) { this.force = force; } + + } diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index a408ec9..ee4323d 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -1233,10 +1233,50 @@ public class Worm extends GameObject { } // region firing and projectiles //=================================================================================== + private double[] locationProj; + private double massProj; + private long hitpointsProj; + private double forceProj; + public void fire() { - + if (getActionPoints() >= 30 && getWorld() != null) { + Random r = new Random(); + int random = r.nextInt((1 - 0) + 1); + locationProj[0] = cos(getOrientation())*getRadius(); + locationProj[1] = sin(getOrientation())*getRadius(); + if (random == 0) { + propertiesRifle(); + decreaseActionPoints(10); + } + else { + propertiesBazooka(); + decreaseActionPoints(25); + } + new Projectile(this.getWorld(), locationProj, massProj, hitpointsProj, forceProj); + } } + public void propertiesRifle() { + massProj = 10; + forceProj = 1.5; + Random r = new Random(); + hitpointsProj = 0 + r.nextInt((10-0)/2) *2; + } + + public void propertiesBazooka() { + massProj = 300; + forceProj = 2.5 + getActionPoints()/8; + Random r = new Random(); + hitpointsProj = 0 + r.nextInt((10-0)/(2+1)) *(2+1); + } + + public void hitByRifle() { + decreaseHitPoints(hitpointsProj); + } + + public void hitByBazooka() { + decreaseHitPoints(hitpointsProj * (long) forceProj); + } // =================================================================================== // endregion }