/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); //checks which game state the game currently is in. switch (SceneController.CurrentState) { case SceneController.State.LevelPicker: if (nameChosen && !helpMenuActive) { UIMapController.UIMapReaderUpdate(gameTime); } else if (!helpMenuActive) { InptController.MapUDrawpdate(spriteBatch); } if (helpMenuActive) { tileHelpMenu.Draw(spriteBatch); } break; case SceneController.State.HighScore: if (mapHasBeenSelected && !helpMenuActive) { selectedMap.DrawMap(spriteBatch, textures); if (!hasBeenCalledd) { WaveController.Initilazie(selectedMap.PathPoints, enemyTextures); PlayerController.Initalize(spriteBatch); UITowerController.Initilalize(towerTextures, projectileTexture); hasBeenCalledd = true; } WaveController.Update(spriteBatch); PlayerController.draw(spriteBatch); TowerController.Update(gameTime, spriteBatch); } else if (!helpMenuActive) { interactableMenu.Draw(spriteBatch); } if (helpMenuActive) { gameHelpMenu.Draw(spriteBatch); } break; case SceneController.State.Quit: this.Exit(); break; default: SceneController.MenuDraw(spriteBatch); break; } spriteBatch.End(); // TODO: Add your drawing code here base.Draw(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { //checks which game state the game currently is in. switch (SceneController.CurrentState) { case SceneController.State.LevelPicker: KeyboardState keyboardState = Keyboard.GetState(); if (!nameChosen && !helpMenuActive) //checks if the name is chosen and if the help menu is active. { nameChosen = InptController.InputUpdate(gameTime); } if (!helpMenuActive) //checks if the help menu is active. { if (gameTime.TotalGameTime.TotalMilliseconds > delay + previouslyActiveMenuTime && keyboardState.IsKeyDown(Keys.H)) { helpMenuActive = true; previouslyActiveMenuTime = gameTime.TotalGameTime.TotalMilliseconds; } } else if (helpMenuActive) { if (keyboardState.IsKeyDown(Keys.H) && gameTime.TotalGameTime.TotalMilliseconds > delay + previouslyActiveMenuTime) { helpMenuActive = false; previouslyActiveMenuTime = gameTime.TotalGameTime.TotalMilliseconds; } } break; case SceneController.State.HighScore: KeyboardState keyboardState1 = Keyboard.GetState(); if (mapHasBeenSelected && !helpMenuActive) { selectedMap.MapUpdate(); } if (!helpMenuActive) { if (gameTime.TotalGameTime.TotalMilliseconds > delay + previouslyActiveMenuTime && keyboardState1.IsKeyDown(Keys.H)) { helpMenuActive = true; previouslyActiveMenuTime = gameTime.TotalGameTime.TotalMilliseconds; } } else if (helpMenuActive) { if (keyboardState1.IsKeyDown(Keys.H) && gameTime.TotalGameTime.TotalMilliseconds > delay + previouslyActiveMenuTime) { helpMenuActive = false; previouslyActiveMenuTime = gameTime.TotalGameTime.TotalMilliseconds; } } UITowerController.Update(); break; case SceneController.State.Quit: this.Exit(); break; default: SceneController.CurrentState = SceneController.MenuUpdate(gameTime); break; } // TODO: Add your update logic here base.Update(gameTime); }