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