Worm: projectile

This commit is contained in:
Leen Dereu
2018-05-04 15:15:50 +02:00
parent 383bf84152
commit 8c7a078aa1

View File

@@ -1225,16 +1225,49 @@ public class Worm extends GameObject {
} }
// region firing and projectiles // region firing and projectiles
//=================================================================================== //===================================================================================
private double[] locationProj;
private double massProj;
private long hitpointsProj;
private double forceProj;
public void fire() { 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 createRifle() { public void propertiesRifle() {
massProj = 10;
forceProj = 1.5;
Random r = new Random();
hitpointsProj = 0 + r.nextInt((10-0)/2) *2;
} }
public void createBazooka() { 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 // endregion