Removed ghost == null checks that are no longer necessary

This commit is contained in:
Matt Low 2019-12-28 23:35:29 +04:00
parent 3fe14e6e5d
commit 9b06b294f4

View File

@ -106,7 +106,7 @@ public class PlayState extends LevelState {
if (pacman.alive && newGameTimer <= 0) { if (pacman.alive && newGameTimer <= 0) {
for (Ghost ghost : ghosts) { for (Ghost ghost : ghosts) {
if (ghost == null || (pointsTimer > 0 && ghost == lastGhostCaptured)) { if (pointsTimer > 0 && ghost == lastGhostCaptured) {
continue; continue;
} }
ghost.render(game.batch, 0, 16); ghost.render(game.batch, 0, 16);
@ -174,7 +174,7 @@ public class PlayState extends LevelState {
frightTimer -= dt; frightTimer -= dt;
if (frightTimer <= 0) { if (frightTimer <= 0) {
for (Ghost ghost : ghosts) { for (Ghost ghost : ghosts) {
if (ghost == null || ghost.currentBehaviour instanceof ReturnToBase) continue; if (ghost.currentBehaviour instanceof ReturnToBase) continue;
ghost.caught = false; ghost.caught = false;
ghost.currentBehaviour = ghost.chaseBehaviour; ghost.currentBehaviour = ghost.chaseBehaviour;
ghost.speed = Ghost.GHOST_SPEED; ghost.speed = Ghost.GHOST_SPEED;
@ -216,9 +216,6 @@ public class PlayState extends LevelState {
if (!pacmanCaught) { if (!pacmanCaught) {
for (Ghost ghost : ghosts) { for (Ghost ghost : ghosts) {
if (ghost == null) {
continue;
}
ghost.update(dt); ghost.update(dt);
if (ghost.onSameTile(pacman)) { if (ghost.onSameTile(pacman)) {
@ -377,7 +374,7 @@ public class PlayState extends LevelState {
public void eatPowerPellet(float x, float y) { public void eatPowerPellet(float x, float y) {
pelletEaten(x, y); pelletEaten(x, y);
for (Ghost ghost : ghosts) { for (Ghost ghost : ghosts) {
if (ghost == null || ghost.currentBehaviour instanceof ReturnToBase) continue; if (ghost.currentBehaviour instanceof ReturnToBase) continue;
ghost.caught = false; ghost.caught = false;
ghost.currentBehaviour = ghost.frightBehaviour; ghost.currentBehaviour = ghost.frightBehaviour;
ghost.currDirection = ghost.currDirection.getOpposite(); ghost.currDirection = ghost.currDirection.getOpposite();