using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input.Touch; using Penguloon.Controls; namespace Penguloon.Scenes { class StatsScene : SceneBase { MessageBox ResetConfirmationBox; public StatsScene(Main main) : base(main) { UserdataManager.Level = UserdataManager.GetLevel(); } public override void CreateControls() { Vector2 MsgBoxSize = new Vector2(900, 550); Button btnBack = new Button(this, new Vector2(50, 50), StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.LevelSelectionBack)); ButtonReset resetBtn = new ButtonReset(this, new Vector2(50 + StaticUIValues.MenuButtonSize.X + 20, 50), new Vector2(StaticUIValues.MenuButtonSize.Y, StaticUIValues.MenuButtonSize.Y)); ResetConfirmationBox = new MessageBox(this, new Vector2((StaticUIValues.ScreenViewport.X / 2) - (MsgBoxSize.X / 2), (StaticUIValues.ScreenViewport.Y / 2) - (MsgBoxSize.Y / 2)), MsgBoxSize, Main.Resources.GetString(Resource.String.StatsResetConfirmation)); btnBack.OnClick += BtnStart_OnClick; resetBtn.OnClick += ResetBtn_OnClick; ResetConfirmationBox.OnYes += ResetConfirmationBox_OnYes; Controls.Add(btnBack); Controls.Add(resetBtn); } private void ResetConfirmationBox_OnYes(object sender, EventArgs e) { UserdataManager.ReadData(Main.Context, true); UserdataManager.Level = UserdataManager.GetLevel(); } private void ResetBtn_OnClick(object sender, ClickArgs e) { ResetConfirmationBox.State = IngameOptionsState.Show; } private void BtnStart_OnClick(object sender, ClickArgs e) { SceneManager.SelectedScene = SelectedScene.Menu; } public override void Update(float deltaTime, TouchLocation[] touchLocations) { ResetConfirmationBox.Update(deltaTime, touchLocations); base.Update(deltaTime, touchLocations); } public override void Draw(float deltaTime) { // background Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/background"), destinationRectangle: new Rectangle(0, 0, (int)StaticUIValues.ScreenViewport.X, (int)StaticUIValues.ScreenViewport.Y)); DrawSnowflakes(); int borderHorizontalY = 50 + (int)StaticUIValues.MenuButtonSize.Y + 50; //border top Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), destinationRectangle: new Rectangle(50, borderHorizontalY - 7, StaticUIValues.BorderWidth * 2, StaticUIValues.BorderWidth * 2)); //border bottom Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), destinationRectangle: new Rectangle(50, (int)StaticUIValues.ScreenViewport.Y - 50 - (StaticUIValues.BorderWidth * 2) + 7, StaticUIValues.BorderWidth * 2, StaticUIValues.BorderWidth * 2)); //border vertical Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border"), destinationRectangle: new Rectangle(50, borderHorizontalY, StaticUIValues.BorderWidth * 2, (int)StaticUIValues.ScreenViewport.Y - (borderHorizontalY) - 50)); DrawStats(borderHorizontalY); base.Draw(deltaTime); ResetConfirmationBox.Draw(deltaTime); } private void DrawStats(int borderHorizontalY) { DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), Main.Resources.GetString(Resource.String.StatsTotalStatsTitle), new Vector2(120, borderHorizontalY), new Vector2(0, 0), TextAllignment.LeftTop, Color.FromNonPremultiplied(111, 138, 183, 255), Color.Black, 2); int martinXRight = StaticUIValues.StatsMarginXRight; DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), UserdataManager.Level.ToString(), new Vector2((int)StaticUIValues.ScreenViewport.X - martinXRight, 75), new Vector2(0, 0), TextAllignment.RightTop, Color.White, Color.Black, 2); DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), Main.Resources.GetString(Resource.String.StatsLevel) + " ", new Vector2((int)StaticUIValues.ScreenViewport.X - martinXRight - ContentManager.GetFont(StaticUIValues.StatsFont).MeasureString(UserdataManager.Level.ToString()).X, 75), new Vector2(0, 0), TextAllignment.RightTop, Color.FromNonPremultiplied(111, 138, 183, 255), Color.Black, 2); // Total kills DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), Main.Resources.GetString(Resource.String.StatsTotalKills), new Vector2(120, borderHorizontalY + 25 + (StaticUIValues.StatsSpacingY * 1)), new Vector2(0, 0), TextAllignment.LeftTop, Color.White, Color.Black, 2); // Total kills stat DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), UserdataManager.TotalKills.ToString(), new Vector2(StaticUIValues.ScreenViewport.X - martinXRight, borderHorizontalY + 25 + (StaticUIValues.StatsSpacingY * 1)), new Vector2(0, 0), TextAllignment.RightTop, Color.White, Color.Black, 2); // Total games DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), Main.Resources.GetString(Resource.String.StatsTotalGames), new Vector2(120, borderHorizontalY + 25 + (StaticUIValues.StatsSpacingY * 2)), new Vector2(0, 0), TextAllignment.LeftTop, Color.White, Color.Black, 2); // Total games stat DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), UserdataManager.GamesPlayed.ToString(), new Vector2(StaticUIValues.ScreenViewport.X - martinXRight, borderHorizontalY + 25 + (StaticUIValues.StatsSpacingY * 2)), new Vector2(0, 0), TextAllignment.RightTop, Color.White, Color.Black, 2); // Total money spent DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), Main.Resources.GetString(Resource.String.StatsTotalMoneySpent), new Vector2(120, borderHorizontalY + 25 + (StaticUIValues.StatsSpacingY * 3)), new Vector2(0, 0), TextAllignment.LeftTop, Color.White, Color.Black, 2); // Total money spent stat DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), UserdataManager.TotalMoneySpent.ToString(), new Vector2(StaticUIValues.ScreenViewport.X - martinXRight, borderHorizontalY + 25 + (StaticUIValues.StatsSpacingY * 3)), new Vector2(0, 0), TextAllignment.RightTop, Color.White, Color.Black, 2); /////////////////// DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), Main.Resources.GetString(Resource.String.StatsBestStatsTitle), new Vector2(120, borderHorizontalY + 50 + (StaticUIValues.StatsSpacingY * 4)), new Vector2(0, 0), TextAllignment.LeftTop, Color.FromNonPremultiplied(111, 138, 183, 255), Color.Black, 2); // Total kills DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), Main.Resources.GetString(Resource.String.StatsBestKills), new Vector2(120, borderHorizontalY + 75 + (StaticUIValues.StatsSpacingY * 5)), new Vector2(0, 0), TextAllignment.LeftTop, Color.White, Color.Black, 2); // Total kills stat DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), UserdataManager.HighestKills.ToString(), new Vector2(StaticUIValues.ScreenViewport.X - martinXRight, borderHorizontalY + 75 + (StaticUIValues.StatsSpacingY * 5)), new Vector2(0, 0), TextAllignment.RightTop, Color.White, Color.Black, 2); // Total games DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), Main.Resources.GetString(Resource.String.StatsBestRound), new Vector2(120, borderHorizontalY + 75 + (StaticUIValues.StatsSpacingY * 6)), new Vector2(0, 0), TextAllignment.LeftTop, Color.White, Color.Black, 2); // Total games stat DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), UserdataManager.HighestRound.ToString(), new Vector2(StaticUIValues.ScreenViewport.X - martinXRight, borderHorizontalY + 75 + (StaticUIValues.StatsSpacingY * 6)), new Vector2(0, 0), TextAllignment.RightTop, Color.White, Color.Black, 2); } } }