public void Update(GameTime gameTime, KeyboardState ks, GameBoard board, int currentDarwinX, int currentDarwinY) { base.Update(gameTime); if (this.canEventHappen()) { updateDarwinTransformState(ks); this.setEventFalse(); } moveDarwin(ks, board, currentDarwinX, currentDarwinY); setPictureSize(board.getSquareWidth(), board.getSquareLength()); }
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()) { if (!darwin.isZombie()) { checkForGameOver(firstZombie); checkForGameOver(fastZombie1); } darwin.Update(gameTime, ks, board, darwin.X, darwin.Y); } secondStair.Update(gameTime, darwin); firstZombie.setPictureSize(board.getSquareWidth(), board.getSquareLength()); firstZombie.Update(gameTime, darwin, brain); foreach (Leaf leaf in this.leaves) { leaf.Update(darwin); } fastZombie1.setPictureSize(board.getSquareWidth(), board.getSquareLength()); fastZombie1.Update(gameTime, darwin, brain); //secondZombie.setPictureSize(board.getSquareWidth(), board.getSquareLength()); //secondZombie.Update(gameTime, darwin, brain); //thirdZombie.setPictureSize(board.getSquareWidth(), board.getSquareLength()); //thirdZombie.Update(gameTime, darwin, brain); firstSwitch.Update(gameTime, ks, darwin); secondSwitch.Update(gameTime, ks, darwin); brain.Update(gameTime, ks, darwin); checkForSwitchToLevelFour(); //checkForGameWin(); if (ks.IsKeyDown(Keys.H) && messageModeCounter > 10) { messageMode = true; messageModeCounter = 0; } messageModeCounter++; }
//protected override void UnloadContent() { } public void Update(GameTime gameTime) { switch (gameState.getState()) { case GameState.state.Start: UpdateStartState(); break; case GameState.state.Start2: UpdateStartState2(); break; case GameState.state.Level: // decide if screen should be played normally or frozen for death animation or messages if (!messageMode && !gameOver) { UpdateLevelState(gameTime); } else if (messageMode) { UpdateMessageMode(); } else { if (playDeathSound) { if (fellDownPit) { fallScreamSound.Play(); } else { deathScreamSound.Play(); } playDeathSound = false; } // for changing darwin's sprite when he falls into the vortex fellDownCounter++; if (fellDownPit && darwin.destination.Width > 0 && darwin.destination.Height > 0 && fellDownCounter > 5) { darwin.destination.Width -= (int)((float)board.getSquareWidth() * 0.1); darwin.destination.Height -= (int)((float)board.getSquareLength() * 0.1); fellDownCounter = 0; } // kill darwin darwin.setDarwinDead(); darwin.setZombie(); UpdateLevelState(gameTime); gameOverCounter++; if (gameOverCounter > 200) { gameState.setState(GameState.state.End); gameOverCounter = 0; } } break; case GameState.state.End: UpdateEndState(); break; } }
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); // only check for deaths if neccessary if (darwin.isDarwinAlive()) { if (!darwin.isZombie()) { if (firstZombie.isZombieAlive()) { checkForGameOver(firstZombie); } if (secondZombie.isZombieAlive()) { checkForGameOver(secondZombie); } if (thirdZombie.isZombieAlive()) { checkForGameOver(thirdZombie); } if (fourthZombie.isZombieAlive()) { checkForGameOver(fourthZombie); } } if (darwin.isZombie()) { checkForGameOver(cannibalZombie); } darwin.Update(gameTime, ks, board, darwin.X, darwin.Y); } stairs.Update(gameTime, darwin); firstZombie.setPictureSize(board.getSquareWidth(), board.getSquareLength()); firstZombie.Update(gameTime, darwin); secondZombie.setPictureSize(board.getSquareWidth(), board.getSquareLength()); secondZombie.Update(gameTime, darwin); thirdZombie.setPictureSize(board.getSquareWidth(), board.getSquareLength()); thirdZombie.Update(gameTime, darwin); fourthZombie.setPictureSize(board.getSquareWidth(), board.getSquareLength()); fourthZombie.Update(gameTime, darwin); cannibalZombie.setPictureSize(board.getSquareWidth(), board.getSquareLength()); cannibalZombie.Update(gameTime, darwin); potion.Update(gameTime, ks, darwin, zTime); //checkForGameWin(); if (isAllZombiesDead()) { foreach (BasicObject bo in removableWalls) { if (!board.isGridPositionOpen(bo)) { board.setGridPositionOpen(bo); } } if (playSound) { revealSound.Play(); playSound = false; } } checkUpdateToLevelThree(); if (ks.IsKeyDown(Keys.H) && messageModeCounter > 10) { messageMode = true; messageModeCounter = 0; } messageModeCounter++; }