aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/Weapon.java
diff options
context:
space:
mode:
authormafaldo <mafaldo@heavyhammer.home>2018-02-11 12:21:15 +0100
committermafaldo <mafaldo@heavyhammer.home>2018-02-11 12:21:15 +0100
commita9a5bc0189d316de863bbdc8c3a425706b6ade84 (patch)
treee92db501cfa040cad315b535cb326abb3f086348 /src/main/java/Weapon.java
parenttiles bound to actors, remove Player and Enemy (diff)
downloadSubconscious-old-a9a5bc0189d316de863bbdc8c3a425706b6ade84.tar.gz
Subconscious-old-a9a5bc0189d316de863bbdc8c3a425706b6ade84.zip
add pan, add zoom, add weapon
Diffstat (limited to 'src/main/java/Weapon.java')
-rw-r--r--src/main/java/Weapon.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/Weapon.java b/src/main/java/Weapon.java
new file mode 100644
index 0000000..824ad6f
--- /dev/null
+++ b/src/main/java/Weapon.java
@@ -0,0 +1,52 @@
+public class Weapon {
+ private final int RANGE;
+ private final int DAMAGE;
+ private final int WARMUP;
+ private final int BURSTCOUNT;
+
+ private int coolDown;
+
+ public Weapon(int damage, int range, int burstcount, int warmup) {
+ this.coolDown = 0;
+ this.DAMAGE = damage;
+ this.RANGE = range;
+ this.BURSTCOUNT = burstcount;
+ this.WARMUP = warmup;
+ }
+
+ public int getDamage() {
+ return this.DAMAGE;
+ }
+
+ public int getBurst() {
+ return this.BURSTCOUNT;
+ }
+
+ public int getRange() {
+ return this.RANGE;
+ }
+
+ public boolean canShoot() {
+ if (coolDown <= 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean shoot(Actor actor, double probability) {
+ if (coolDown <= 0) {
+ actor.damage((int)((this.DAMAGE*probability)*(double)this.BURSTCOUNT));
+ this.coolDown = this.WARMUP;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public void tick() {
+ if (coolDown > 0) {
+ coolDown--;
+ }
+ }
+}