Merge branch 'master' of gitlab.principis.be:OGP/worms
This commit is contained in:
@@ -27,4 +27,6 @@ public class Projectile extends GameObject {
|
|||||||
public void setForce(double force) {
|
public void setForce(double force) {
|
||||||
this.force = force;
|
this.force = force;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1233,10 +1233,50 @@ 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 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
|
// endregion
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user