/// <summary> /// If the level is over, draws text describing the level's outcome. /// </summary> private void DrawLevelEndIfNecessary() { if (isLevelEnd) { string stringToDisplay = string.Empty; if (isUserWon) { if (FinalScore != 0 && HighScoreScreen.IsInHighscores(FinalScore)) { stringToDisplay = "It's a new\nHigh-Score!"; } else { stringToDisplay = "You Win!"; } } else { stringToDisplay = "Time Is Up!"; } Vector2 stringVector = font36px.MeasureString(stringToDisplay) * ScreenManager.SpriteBatch.ScaleVector; ScreenManager.SpriteBatch.DrawString(font36px, stringToDisplay, new Vector2(ScreenManager.GraphicsDevice.Viewport.Width / 2 - stringVector.X / 2, ScreenManager.GraphicsDevice.Viewport.Height / 2 - stringVector.Y / 2), Color.White); } }
/// <summary> /// Starts new level or exit to High Score /// </summary> /// <param name="input"></param> private void StartNewLevelOrExit(InputState input) { // If there is no next level - go to high score screen if (!difficultyMode.HasValue) { // If is in high score, gets is name if (GameplayScreen.FinalScore != 0 && HighScoreScreen.IsInHighscores(GameplayScreen.FinalScore)) { Guide.BeginShowKeyboardInput(PlayerIndex.One, "Player Name", "What is your name (max 15 characters)?", "Player", AfterPlayerEnterName, null); } else { foreach (GameScreen screen in ScreenManager.GetScreens()) { screen.ExitScreen(); } ScreenManager.AddScreen(new BackgroundScreen("highScoreScreen"), null); ScreenManager.AddScreen(new HighScoreScreen(), null); } } // If not already loading else if (!isLoading) { // Start loading the resources in an additional thread thread = new Thread(new ThreadStart(gameplayScreen.LoadAssets)); isLoading = true; thread.Start(); } }
/// <summary> /// Starts new level or exit to High Score /// </summary> /// <param name="input"></param> private void StartNewLevelOrExit(InputState input) { // If there is no next level - go to high score screen if (!difficultyMode.HasValue) { // If is in high score, gets is name if (GameplayScreen.FinalScore != 0 && HighScoreScreen.IsInHighscores(GameplayScreen.FinalScore)) { Guide.BeginShowKeyboardInput(PlayerIndex.One, "Player Name", "What is your name (max 15 characters)?", "Player", AfterPlayerEnterName, null); } else { foreach (GameScreen screen in ScreenManager.GetScreens()) { screen.ExitScreen(); } ScreenManager.AddScreen(new BackgroundScreen("highScoreScreen"), null); ScreenManager.AddScreen(new HighScoreScreen(), null); } } // If not already loading else if (!isLoading) { #if MONOMAC // Start loading the resources on main thread // If not then all sorts of errors happen for // AutoReleasPools and OpenGL does not handle // multiple thread to well when using Thread MonoMac.AppKit.NSApplication.SharedApplication.BeginInvokeOnMainThread(delegate { gameplayScreen.LoadAssets(); isLoading = false; assetsLoaded = true; }); #else // Start loading the resources in an additional thread thread = new Thread(new ThreadStart(gameplayScreen.LoadAssets)); isLoading = true; thread.Start(); #endif } }
/// <summary> /// Checks if the user's score is a high score. /// </summary> /// <returns>True if the user has a high score, false otherwise.</returns> private bool CheckIsInHighScore() { // User can be at high score only if he is at Hard level. return(gameDifficultyLevel == DifficultyMode.Hard && HighScoreScreen.IsInHighscores(Score)); }