// checks for deaths caused by babies private void checkForGameOver() { foreach (BabyZombie b in nurseryOne.babies) { if (b.exploding && b.isZombieAlive()) { if (darwin.isOnTop(b) || darwin.isOnTop(b.X, b.Y - 1) || darwin.isOnTop(b.X - 1, b.Y) || darwin.isOnTop(b.X, b.Y + 1) || darwin.isOnTop(b.X + 1, b.Y)) { gameOver = true; } } } foreach (BabyZombie b in nurseryTwo.babies) { if (b.exploding && b.isZombieAlive()) { if (darwin.isOnTop(b) || darwin.isOnTop(b.X, b.Y - 1) || darwin.isOnTop(b.X - 1, b.Y) || darwin.isOnTop(b.X, b.Y + 1) || darwin.isOnTop(b.X + 1, b.Y)) { gameOver = true; } } } }
private void checkForFlameDeath(Flame flame, Darwin darwin) { if (darwin.isOnTop(flame)) { this.gameOver = true; } }
public void Update(Darwin darwin) { // if darwin is on top of the leaf if (darwin.isOnTop(this)) { // we want to break it, and wake up the zombie who is listening to it breakLeaf(); parentZombie.wakeUp(); parentZombie.assignLeaf(this); } }
private void checkForFlameDeath(Flame flame, Darwin darwin) { if(darwin.isOnTop(flame)) { this.gameOver = true; } }
private void UpdateLevelState(GameTime gameTime) { if (darwin.isZombie() && darwin.isDarwinAlive()) { if (zTime.isTimedOut()) { gameOver = true; } else { zTime.Update(gameTime); } } KeyboardState ks = Keyboard.GetState(); checkForExitGame(ks); updateKeyHeldDown(ks); if (darwin.isDarwinAlive()) { foreach (Flame flame in flames) { this.checkForFlameDeath(flame, darwin); } darwin.Update(gameTime, ks, board, darwin.X, darwin.Y); } stairs.Update(gameTime, darwin); potion.Update(gameTime, ks, darwin, zTime); foreach (Box b in boxes) { b.Update(gameTime, ks, darwin); } foreach (Vortex v in vortexes) { v.Update(gameTime, ks); // maybe update this so that boxes can't go in holes foreach (Box b in boxes) { v.CollisionWithBO(b, board); } } northZombie.Update(darwin); southZombie.Update(darwin); eastZombie.Update(darwin); westZombie.Update(darwin); if (!darwin.isZombie()) { if (!northZombie.isPatrolling()) { if (darwin.X == northZombie.X) { flames.AddLast(new Flame(board, northZombie.X, northZombie.Y + 1)); flames.AddLast(new Flame(board, northZombie.X, northZombie.Y + 2)); flames.AddLast(new Flame(board, northZombie.X, northZombie.Y + 3)); northZombie.doFlameSound(); } } else if (!southZombie.isPatrolling()) { if (darwin.X == southZombie.X) { flames.AddLast(new Flame(board, southZombie.X, southZombie.Y - 1)); flames.AddLast(new Flame(board, southZombie.X, southZombie.Y - 2)); flames.AddLast(new Flame(board, southZombie.X, southZombie.Y - 3)); southZombie.doFlameSound(); } } else if (!eastZombie.isPatrolling()) { if (darwin.Y == eastZombie.Y) { flames.AddLast(new Flame(board, eastZombie.X - 1, eastZombie.Y)); flames.AddLast(new Flame(board, eastZombie.X - 2, eastZombie.Y)); flames.AddLast(new Flame(board, eastZombie.X - 3, eastZombie.Y)); eastZombie.doFlameSound(); } } else if (!westZombie.isPatrolling()) { if (darwin.Y == westZombie.Y) { flames.AddLast(new Flame(board, westZombie.X + 1, westZombie.Y)); flames.AddLast(new Flame(board, westZombie.X + 2, westZombie.Y)); flames.AddLast(new Flame(board, westZombie.X + 3, westZombie.Y)); westZombie.doFlameSound(); } } } foreach (Flame flame in flames) { flame.Update(); if (!flame.isAlive()) { //flames.Remove(flame); } } if (darwin.isDarwinAlive()) { if (snake.isZombieAlive()) { updateSnakeCollision(snake, darwin, gameTime); } if (snake2.isZombieAlive()) { updateSnakeCollision(snake2, darwin, gameTime); } if (snake3.isZombieAlive()) { updateSnakeCollision(snake3, darwin, gameTime); } if (snake4.isZombieAlive()) { updateSnakeCollision(snake4, darwin, gameTime); } } foreach (Vortex v in vortexes) { if (darwin.isOnTop(v)) { fellDownPit = true; gameOver = true; } } checkForGameWin(); checkForSwitchToLevelSix(); if (ks.IsKeyDown(Keys.H) && messageModeCounter > 10) { messageMode = true; messageModeCounter = 0; } messageModeCounter++; }