public bool Equals(LevelRecord other) { if (other == null) { return(false); } else { return((score == other.score) && (time == other.time) && (accuracy == other.accuracy) && (shotsFired == other.shotsFired)); } }
/// <summary> /// Returns a new LevelRecord with the best data /// </summary> /// <param name="newRecord"></param> /// <returns></returns> public LevelRecord UpdateRecord(LevelRecord newRecord) { if (this == ZeroRecord) { return(newRecord); } else { int bestScore = (score >= newRecord.score) ? score : newRecord.score; float bestTime = (time <= newRecord.time) ? time : newRecord.time; int bestShotsFired = (shotsFired <= newRecord.shotsFired) ? shotsFired : newRecord.shotsFired; float bestAccuracy = (accuracy >= newRecord.accuracy) ? accuracy : newRecord.accuracy; return(new LevelRecord(bestScore, bestTime, bestShotsFired, bestAccuracy)); } }
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(); } }