Add canShoot attribute to ShootingEntity.

This commit is contained in:
Jan Philipp Timme 2014-11-04 20:22:51 +01:00
parent aedbd55159
commit a91a60381c
4 changed files with 18 additions and 3 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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