/// <summary> /// Run game screen. Called each frame. /// </summary> /// <param name="game">Form for access to asteroid manager and co</param> public void Run(XnaShooterGame game) { // Render background game.RenderMenuBackground(); // Credits int xPos = 50 * BaseGame.Width / 1024; int yPos = 260 * BaseGame.Height / 768; TextureFont.WriteText(xPos, yPos, "Credits"); WriteCreditsWithLink(xPos, yPos+56, "Idea, Design, Programming", "Benjamin Nitschke (abi)", "http://abi.exdream.com", game); WriteCredits(xPos, yPos + 137, "Thanks fly out to", "Leif Griga, Christoph Rienaecker (WAII),"); WriteCredits(xPos, yPos + 177, "", "Boje Holtz, Enrico Cieslik (Judge),"); WriteCredits(xPos, yPos + 217, "", "Kai Walter (for some sound effects),"); WriteCredits(xPos, yPos + 257, "", "ZMan (www.thezbuffer.com),"); WriteCredits(xPos, yPos + 297, "", "Christina Storm, the XNA team"); WriteCredits(xPos, yPos + 337, "", "and the .NET teams of Microsoft."); TextureFont.WriteText(BaseGame.XToRes(150), BaseGame.YToRes(687), "Dedicated to the great XNA Framework."); if (game.RenderMenuButton(MenuButton.Back, new Point(1024 - 230, 768 - 150))) { quit = true; } // if }
/// <summary> /// Run game screen. Called each frame. /// </summary> /// <param name="game">Form for access to asteroid manager and co</param> public void Run(XnaShooterGame game) { // Make sure the textures and models are linked correctly hudTopTexture = game.hudTopTexture; hudBottomTexture = game.hudBottomTexture; landscapeModels = game.landscapeModels; shipModels = game.shipModels; itemModels = game.itemModels; // Render landscape, ships and neutral objects RenderLevelBackground( //tst: 30+ Player.gameTimeMs / 64.0f);//66.0f);//33.0f); // Handle game logic, move player around, weapons, collisions, etc. Player.HandleGameLogic(this); // Handle effect stuff BaseGame.effectManager.HandleAllEffects(); // Render hud on top of 3d stuff RenderHud(); // End game if escape was pressed or game is over and space or mouse // button was pressed. if (Input.KeyboardEscapeJustPressed || Input.GamePadBackJustPressed || (Player.GameOver && (Input.KeyboardSpaceJustPressed || Input.GamePadAJustPressed || Input.GamePadBJustPressed || Input.GamePadXJustPressed || Input.GamePadXJustPressed || Input.MouseLeftButtonJustPressed))) { // Upload new highscore (as we currently are in game, // no bonus or anything will be added, this score is low!) Player.SetGameOverAndUploadHighscore(); // Reset camera to origin and notify we are not longer in game mode XnaShooterGame.camera.SetPosition(Vector3.Zero); // Quit to the main menu quit = true; } // if }
/// <summary> /// Run game screen. Called each frame. /// </summary> /// <param name="game">Form for access to asteroid manager and co</param> public void Run(XnaShooterGame game) { if (xInputMenuSelection < 0) { xInputMenuSelection = 0; SelectMenuItemForXInput(); } // if if (resetCamera) { resetCamera = false; XnaShooterGame.camera.SetPosition(Vector3.Zero); xInputMenuSelection = 0; } // if // Render background game.RenderMenuBackground(); // Show all buttons int buttonNum = 0; MenuButton[] menuButtons = new MenuButton[] { MenuButton.Missions, MenuButton.Highscore, MenuButton.Credits, MenuButton.Exit, MenuButton.Back, }; foreach (MenuButton button in menuButtons) //EnumHelper.GetEnumerator(typeof(MenuButton))) // Don't render the back button if (button != MenuButton.Back) { if (game.RenderMenuButton(button, buttonLocations[buttonNum])) { if (button == MenuButton.Missions) game.AddGameScreen(new Mission()); else if (button == MenuButton.Highscore) game.AddGameScreen(new Highscores()); else if (button == MenuButton.Credits) game.AddGameScreen(new Credits()); else if (button == MenuButton.Exit) quit = true; } // if buttonNum++; if (buttonNum >= buttonLocations.Length) break; } // if // Hotkeys, M=Mission, H=Highscores, C=Credits, Esc=Quit if (Input.KeyboardKeyJustPressed(Keys.M)) game.AddGameScreen(new Mission()); else if (Input.KeyboardKeyJustPressed(Keys.H)) game.AddGameScreen(new Highscores()); else if (Input.KeyboardKeyJustPressed(Keys.C)) game.AddGameScreen(new Credits()); else if (Input.KeyboardEscapeJustPressed || Input.GamePadBackJustPressed) quit = true; // If pressing XBox controller up/down change selection if (Input.GamePadDownJustPressed || Input.KeyboardDownJustPressed) { xInputMenuSelection = (xInputMenuSelection + 1) % buttonLocations.Length; SelectMenuItemForXInput(); } // if (Input.GamePad) else if (Input.GamePadUpJustPressed || Input.KeyboardUpJustPressed) { if (xInputMenuSelection <= 0) xInputMenuSelection = buttonLocations.Length; xInputMenuSelection--; SelectMenuItemForXInput(); } // if (Input.GamePad) }
/// <summary> /// Write credits with link /// </summary> /// <param name="xPos">X coordinate</param> /// <param name="yPos">Y coordinate</param> /// <param name="leftText">Left text</param> /// <param name="rightText">Right text</param> /// <param name="linkText">Link text</param> private void WriteCreditsWithLink(int xPos, int yPos, string leftText, string rightText, string linkText, XnaShooterGame game) { WriteCredits(xPos, yPos, leftText, rightText); // Process link (put below rightText) bool overLink = Input.MouseInBox(new Rectangle( xPos + 440, yPos + 8 + TextureFont.Height, 200, TextureFont.Height)); TextureFont.WriteText(xPos + 440, yPos /*+ 8*/ + TextureFont.Height, linkText, overLink ? Color.Red : Color.White); if (overLink && Input.MouseLeftButtonJustPressed) { #if !XBOX360 Process.Start(linkText); Thread.Sleep(100); #endif } // if }
/// <summary> /// Run game screen. Called each frame. /// </summary> /// <param name="game">Form for access to asteroid manager and co</param> public void Run(XnaShooterGame game) { // Render background game.RenderMenuBackground(); // Show highscores, allow to select between local highscores, // online highscores this hour and online highscores best of all time. int xPos = 100 * BaseGame.Width / 1024; int yPos = 260 * BaseGame.Height / 768; TextureFont.WriteText(xPos, yPos, "Highscores:"); // Local Highscores Rectangle rect = new Rectangle( xPos + 210 * BaseGame.Width / 1024, yPos + 0 * BaseGame.Height / 768, 130, 28); bool highlighted = Input.MouseInBox(rect); TextureFont.WriteText(rect.X, rect.Y, "Local", highscoreMode == HighscoreModes.Local ? Color.Red : highlighted ? Color.LightSalmon : Color.White); if (highlighted && Input.MouseLeftButtonJustPressed) highscoreMode = HighscoreModes.Local; yPos = 310 * BaseGame.Height / 768; Highscore[] selectedHighscores = highscoreMode == HighscoreModes.Local ? highscores : onlineHighscores; for (int num = 0; num < NumOfHighscores; num++) { Color col = Input.MouseInBox(new Rectangle( xPos, yPos + num * 30, 600 + 200, 28)) ? Color.White : ColorHelper.FromArgb(200, 200, 200); TextureFont.WriteText(xPos, yPos + num * 29, (1 + num) + ".", col); TextureFont.WriteText(xPos + 50, yPos + num * 30, selectedHighscores[num].name, col); TextureFont.WriteText(xPos + 340, yPos + num * 30, "Score: " + selectedHighscores[num].points, col); TextureFont.WriteText(xPos + 610, yPos + num * 30, "Mission: " + selectedHighscores[num].level, col); } // for (num) if (game.RenderMenuButton(MenuButton.Back, new Point(1024 - 230, 768 - 150))) { quit = true; } // if }