/// <summary> /// A helper method that will initialize the main menu whenever it is called /// </summary> public void SwitchToMainMenu() { Soundtrack.Stop(); IsMouseVisible = true; CurrentState = MainGameState.Menu; int height = GraphicsDevice.Viewport.Height; int width = GraphicsDevice.Viewport.Width; buttons = new Button[2]; Texture2D startButton = allTextures["StartButton"]; buttons[0] = new Button(startButton, "StartButton", new Rectangle(width / 2 - startButton.Width / 2, height * 6 / 10 - startButton.Height / 2, startButton.Width, startButton.Height)); Texture2D exitButton = allTextures["ExitButton"]; buttons[1] = new Button(exitButton, "ExitButton", new Rectangle(width / 2 - exitButton.Width / 2, height * 3 / 4 - exitButton.Height / 2, exitButton.Width, exitButton.Height)); indexActiveButton = 0; }
/// <summary> /// A helper method that initializes the game over state when called /// </summary> public void SwitchToGameOver() { Soundtrack.Stop(); laugh.Play(); IsMouseVisible = true; CurrentState = MainGameState.GameOver; int height = GraphicsDevice.Viewport.Height; int width = GraphicsDevice.Viewport.Width; Texture2D background = allTextures["GameOverBackground"]; // scale the buttons to the size of the screen float scale = (float)height / (float)background.Height; buttons = new Button[2]; Texture2D retry = allTextures["GameOverRetry"]; Texture2D exit = allTextures["GameOverExit"]; buttons[0] = new Button(retry, "Retry", new Rectangle((int)(width / 2 - (scale * retry.Width) / 2), (int)(.65 * height), (int)(retry.Width * scale), (int)(retry.Height * scale))); buttons[1] = new Button(exit, "Exit", new Rectangle((int)(width / 2 - (scale * exit.Width) / 2), (int)(.8 * height), (int)(exit.Width * scale), (int)(exit.Height * scale))); indexActiveButton = 0; }