From a91a60381cde4f5f2caec636c56d4cf82d843419 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Tue, 4 Nov 2014 20:22:51 +0100 Subject: [PATCH] Add canShoot attribute to ShootingEntity. --- .../spacescooter/entity/ShootingEntity.java | 18 +++++++++++++++--- .../spacescooter/screen/GameOverScreen.java | 1 + .../spacescooter/screen/GamePausedScreen.java | 1 + .../spacescooter/screen/MainMenuScreen.java | 1 + 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java index 8d9cfd3..821933b 100644 --- a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java @@ -4,6 +4,8 @@ import de.teamteamteam.spacescooter.entity.shot.SingleBlueShot; public abstract class ShootingEntity extends LivingEntity { + private boolean canShoot = true; + private int shootDelay; private int currentShootDelay; private int shootSpawnX; @@ -23,12 +25,22 @@ public abstract class ShootingEntity extends LivingEntity { } protected void shoot() { - if(this.currentShootDelay == 0) { - new SingleBlueShot(this.x + this.shootSpawnX, this.y + this.shootSpawnY, this.shootDirection, this.shootSpeed, this.damageValue); - this.currentShootDelay = this.shootDelay; + if(this.canShoot == true) { + if(this.currentShootDelay == 0) { + new SingleBlueShot(this.x + this.shootSpawnX, this.y + this.shootSpawnY, this.shootDirection, this.shootSpeed, this.damageValue); + this.currentShootDelay = this.shootDelay; + } } } + public void setCanShoot(boolean canShoot) { + this.canShoot = canShoot; + } + + public boolean canShoot() { + return this.canShoot; + } + public void setShootDirection(int direction) { this.shootDirection = direction; } diff --git a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java index 08e1a7f..0665b1f 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java @@ -32,6 +32,7 @@ public class GameOverScreen extends Screen { new Button(GameConfig.windowWidth/2-125, 400); player = new Player(GameConfig.windowWidth/2-170, 309); player.setCanMove(false); + player.setCanShoot(false); } @Override diff --git a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java index b6703a0..de1a889 100644 --- a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java @@ -32,6 +32,7 @@ public class GamePausedScreen extends Screen { new Button(GameConfig.windowWidth/2-125, 400); player = new Player(GameConfig.windowWidth/2-170, 309); player.setCanMove(false); + player.setCanShoot(false); } @Override diff --git a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java index 3a6c311..2b5c562 100644 --- a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java @@ -35,6 +35,7 @@ public class MainMenuScreen extends Screen { new Button(GameConfig.windowWidth/2-125, 500); player = new Player(GameConfig.windowWidth/2-170, 209); player.setCanMove(false); + player.setCanShoot(false); } @Override