示例#1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public PauseMenuScreen(string levelName, string gunName, ShooterGameType gameType, float targetScoreOrTime)
            : base("Paused")
        {
            this.levelName         = levelName;
            this.gunName           = gunName;
            this.gameType          = gameType;
            this.targetScoreOrTime = targetScoreOrTime;

            // Create our menu entries.
            MenuEntry resumeGameMenuEntry   = new MenuEntry("Resume");
            MenuEntry restartGameMenuEntry  = new MenuEntry("Restart");
            MenuEntry medalsMenuEntry       = new MenuEntry("Medals");
            MenuEntry settingsGameMenuEntry = new MenuEntry("Settings");
            MenuEntry quitGameMenuEntry     = new MenuEntry("Quit");

            // Hook up menu event handlers.
            resumeGameMenuEntry.Selected   += OnCancel;
            restartGameMenuEntry.Selected  += RestartGameMenuEntrySelected;
            medalsMenuEntry.Selected       += MedalsMenuEntrySelected;
            settingsGameMenuEntry.Selected += SettingsGameMenuEntrySelected;
            quitGameMenuEntry.Selected     += QuitGameMenuEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(resumeGameMenuEntry);
            MenuEntries.Add(restartGameMenuEntry);
            MenuEntries.Add(medalsMenuEntry);
            MenuEntries.Add(settingsGameMenuEntry);
            MenuEntries.Add(quitGameMenuEntry);

            // Decrease music volume
            MediaPlayer.Volume = MediaPlayer.Volume / 2;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public LevelCompleteMenuScreen(LevelRecord levelRecord, string levelName, string gunName,
                                       ShooterGameType gameType, float targetScoreOrTime)
            : base("Level Complete")
        {
            string doneMenuEntryText = "Done";

            this.levelName         = levelName;
            this.gunName           = gunName;
            this.levelRecord       = levelRecord;
            this.gameType          = gameType;
            this.targetScoreOrTime = targetScoreOrTime;

            levelComplete = true;

            if (gameType != ShooterGameType.ScoreAttack)
            {
                MenuTitle = "Challenge Complete";
            }

            // Check if level was completed
            if ((gameType == ShooterGameType.TargetScore && levelRecord.Score < (int)targetScoreOrTime) ||
                (gameType == ShooterGameType.TimeTrial && levelRecord.Time > targetScoreOrTime) ||
                (gameType == ShooterGameType.BullseyeChallenge && levelRecord.NumBullseyes != levelRecord.NumTargetsShot +
                 levelRecord.NumKnockdowns) ||
                (gameType == ShooterGameType.HeadshotChallenge && levelRecord.NumHeadshots != levelRecord.NumTargetsShot +
                 levelRecord.NumKnockdowns))
            {
                levelComplete     = false;
                MenuTitle         = "Challenge Failed";
                doneMenuEntryText = "Quit";
            }

            if (levelComplete)
            {
                // Update player record
                oldLevelRecord = ActivePlayer.Profile.GetLevelRecord(levelName);
                newRecord      = ActivePlayer.Profile.UpdateLevelRecord(levelName, levelRecord);
            }

            // Create our menu entries
            MenuEntry restartGameMenuEntry = new MenuEntry("Restart");
            MenuEntry doneGameMenuEntry    = new MenuEntry(doneMenuEntryText);

            // Hook up menu event handlers.
            restartGameMenuEntry.Selected += RestartLevelMenuEntrySelected;
            doneGameMenuEntry.Selected    += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(doneGameMenuEntry);
            MenuEntries.Add(restartGameMenuEntry);
        }
        private void LevelMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            string          levelFileName = MenuEntries[SelectedEntry].Text + ".lvl";
            string          gunFileName   = MenuEntries[SelectedEntry].Text.Split(' ')[0] + ".gun";
            WeaponChallenge challenge     = ActivePlayer.Profile.GetWeaponChallenge(levelFileName);

            // Load the level selected
            if (challenge.Status != GameObjects.LevelStatus.Locked)
            {
                if (Guide.IsTrialMode && SelectedEntry > 1)
                {
                    if (ActivePlayer.Profile.IsXboxLiveEnabled() && !Guide.IsVisible)
                    {
                        // Trial mode players can only play first two levels. Offer purchase
                        Guide.ShowMarketplace(ActivePlayer.PlayerIndex);
                    }
                    else
                    {
                        // Play failed sound effect
                        failedSFX.Play();
                    }
                }
                else
                {
                    ShooterGameType gameType          = challenge.GameType;
                    float           targetScoreOrTime = challenge.TargetScoreOrTime;

                    // Create message string
                    string message = string.Empty;
                    if (gameType == ShooterGameType.Targets)
                    {
                        message = "Shoot all of the targets.";
                    }
                    else if (gameType == ShooterGameType.TargetScore)
                    {
                        message = "Get a High Score over " + (int)targetScoreOrTime + ".";
                    }
                    else if (gameType == ShooterGameType.TimeTrial)
                    {
                        message = "Complete level in under " + targetScoreOrTime.ToString("F") + " secs.";
                    }
                    else if (gameType == ShooterGameType.Collection)
                    {
                        message = "Find and collect the Grenade.";
                    }
                    else if (gameType == ShooterGameType.BullseyeChallenge)
                    {
                        message = "Get a Bullseye on every target.";
                    }
                    else if (gameType == ShooterGameType.HeadshotChallenge)
                    {
                        message = "Get a Headshot on every target.";
                    }

                    ShooterGameScreen.originalGunName = ActivePlayer.Profile.SelectedWeaponName;
                    LoadingScreen.Load(ScreenManager, true, message,
                                       ActivePlayer.PlayerIndex,
                                       new ShooterGameScreen(levelFileName, gunFileName,
                                                             gameType, targetScoreOrTime));
                }
            }
            else
            {
                // Play failed sound effect
                failedSFX.Play();
            }
        }
        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.Draw(gameTime);

            ActivePlayer.Profile.DrawGamerTag(TransitionAlpha);

            if (SelectedEntry != MenuEntries.Count - 1)
            {
                string          levelFileName   = MenuEntries[SelectedEntry].Text + ".lvl";
                WeaponChallenge weaponChallenge = ActivePlayer.Profile.GetWeaponChallenge(levelFileName);
                ShooterGameType gameType        = weaponChallenge.GameType;

                string challengeInfo = string.Empty;
                if (gameType == ShooterGameType.BullseyeChallenge)
                {
                    challengeInfo = "BULLSEYE Challenge";
                }
                else if (gameType == ShooterGameType.HeadshotChallenge)
                {
                    challengeInfo = "HEADSHOT Challenge";
                }
                else if (gameType == ShooterGameType.TargetScore)
                {
                    challengeInfo = "Score Challenge";
                }
                else if (gameType == ShooterGameType.TimeTrial)
                {
                    challengeInfo = "Time Trial";
                }
                else if (gameType == ShooterGameType.Collection)
                {
                    challengeInfo = "Collection Challenge";
                }


                // Draw selected level record
                GameObjects.LevelRecord levelRecord = ActivePlayer.Profile.GetLevelRecord(MenuEntries[SelectedEntry].Text + ".lvl");
                string recordData = "High Score    : " + levelRecord.Score + "\n" +
                                    "Best Time     : " + levelRecord.Time.ToString("F") + " Secs" + "\n" +
                                    "Least Shots   : " + levelRecord.ShotsFired + "\n" +
                                    "Best Accuracy : " + levelRecord.Accuracy.ToString("P");

                string recordString = (levelRecord.Equals(GameObjects.LevelRecord.ZeroRecord) ?
                                       "No Record" : "Best Records");
                Vector2 stringSize     = styleFont.MeasureString(recordString);
                Vector2 stringPosition = new Vector2(backgroundRect.X + (backgroundRect.Width - stringSize.X) / 2,
                                                     backgroundRect.Y + stringSize.Y);

                float   challengeInfoScale    = 0.75f;
                Vector2 challengeInfoSize     = styleFont.MeasureString(challengeInfo) * challengeInfoScale;
                Vector2 challengeInfoPosition = new Vector2(backgroundRect.X + (backgroundRect.Width - challengeInfoSize.X) / 2,
                                                            stringPosition.Y + (stringSize.Y * 1.5f));

                string statusString = "LOCKED (" + ActivePlayer.Profile.TotalScore + "/" +
                                      ActivePlayer.Profile.GetWeaponScoreRequirement(MenuEntries[SelectedEntry].Text.Split(' ')[0] + ".gun") + ")";
                GameObjects.LevelStatus status = weaponChallenge.Status;

                if (status == GameObjects.LevelStatus.Unlocked)
                {
                    statusString = "UNLOCKED";
                }
                else if (status == GameObjects.LevelStatus.Completed)
                {
                    statusString = "";
                }
                Vector2 stringSize2     = styleFont.MeasureString(statusString);
                Vector2 stringPosition2 = new Vector2(backgroundRect.X + (backgroundRect.Width - stringSize2.X) / 2,
                                                      backgroundRect.Bottom - (1.5f * stringSize2.Y));

                Vector2 size   = font.MeasureString(recordData);
                Vector2 strPos = new Vector2(backgroundRect.X + (backgroundRect.Width - size.X) / 2,
                                             backgroundRect.Y + (backgroundRect.Height - size.Y) / 2);

                SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

                spriteBatch.Begin();

                spriteBatch.Draw(background, backgroundRect, Color.White * (TransitionAlpha - 0.2f));
                spriteBatch.DrawString(styleFont, recordString, stringPosition, Color.White * TransitionAlpha);
                spriteBatch.DrawString(styleFont, statusString, stringPosition2, Color.White * TransitionAlpha);
                spriteBatch.DrawString(styleFont, challengeInfo, challengeInfoPosition, Color.White * TransitionAlpha,
                                       0.0f, Vector2.Zero, challengeInfoScale, SpriteEffects.None, 0.0f);
                spriteBatch.DrawString(font, recordData, strPos, Color.White * TransitionAlpha);

                // Draw medal icon
                if (status == LevelStatus.Completed)
                {
                    spriteBatch.Draw(medalIcon, medalIconRect, Color.White * TransitionAlpha);
                }

                spriteBatch.End();
            }
        }
示例#5
0
 public WeaponChallenge(LevelStatus status, ShooterGameType gameType, float targetScoreOrTime)
 {
     this.status            = status;
     this.gameType          = gameType;
     this.targetScoreOrTime = targetScoreOrTime;
 }