public override void Activate() { base.Activate(); this.ContentManager = new ContentManager(this.ScreenManager.Game.Content.ServiceProvider); this.ContentManager.RootDirectory = "content"; var lViewport = this.ScreenManager.Game.GraphicsDevice.Viewport; var lScreenSize = new Vector2(lViewport.Width, lViewport.Height); this.BackgroundTexture = this.ContentManager.Load<Texture2D>("Sprites/LevelSelectBackground"); this.BasicFont = this.ContentManager.Load<SpriteFont>("Fonts/MainMenuFont"); this.PlayerManager = new PlayerManager(); this.PlayerManager.Activate(this.ScreenManager.Game); this.BlankTexture = new Texture2D(this.ScreenManager.GraphicsDevice, 1, 1); this.BlankTexture.SetData(new[] { Color.White }); var lButtonTexts = new[] { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "IXX", "XX" }; ; var lButtonTexture = this.ContentManager.Load<Texture2D>("Sprites/LevelSelectionButton"); var lPerfectTexture = this.ContentManager.Load<Texture2D>("Sprites/Perfect"); var lFlawlessTexture = this.ContentManager.Load<Texture2D>("Sprites/Flawless"); var lButtonSize = new Vector2(lButtonTexture.Width, lButtonTexture.Height); this.Buttons = Enumerable.Range(0, 20) .Select(x => new LevelSelectionButton { Text = lButtonTexts[x], LevelIndex = x, ActiveFont = this.BasicFont, InactiveFont = this.BasicFont, Texture = lButtonTexture, PerfectTexture = lPerfectTexture, FlawlessTexture = lFlawlessTexture, Size = lButtonSize, IsAvailable = this.PlayerManager.Player.LevelStats[x].IsAvailable, IsFlawless = this.PlayerManager.Player.LevelStats[x].CompletedFlawlessly, IsPerfect = this.PlayerManager.Player.LevelStats[x].CompletedPerfectly, }) .ToArray(); this.ShopButton = new MainMenuButton { Position = new Vector2(635, 410), Size = new Vector2(150, 60), BlankTexture = this.BlankTexture, ActiveFont = this.BasicFont, InactiveFont = this.BasicFont, Text = "Shop", }; this.BackButton = new MainMenuButton { Position = new Vector2(465, 410), Size = new Vector2(150, 60), BlankTexture = this.BlankTexture, ActiveFont = this.BasicFont, InactiveFont = this.BasicFont, Text = "Back", }; for (int lRowIndex = 0; lRowIndex < 4; lRowIndex++) { for (int lColumnIndex = 0; lColumnIndex < 5; lColumnIndex++) { var lButton = this.Buttons[(lRowIndex * 5) + lColumnIndex]; lButton.Position = new Vector2(5 + (lColumnIndex * (lButton.Size.X + 5)), 17 + (lRowIndex * (lButton.Size.Y + 17))); lButton.Selected += this.Button_Selected; } } }
public override void Activate() { base.Activate(); var lContent = this.ScreenManager.Game.Content; this.MainMenuFont = lContent.Load<SpriteFont>("Fonts/MainMenuFont"); this.MainMenuFontBold = lContent.Load<SpriteFont>("Fonts/MainMenuFontBold"); var lButtonSize = new Vector2(250, 50); this.BackgroundTexture = lContent.Load<Texture2D>("sprites/mainmenubackground"); var lBlankTexture = new Texture2D(this.ScreenManager.GraphicsDevice, 1, 1); lBlankTexture.SetData(new[] { Color.White }); var lCurrentPosition = new Vector2(50f, 275f); this.PlayerManager.Activate(this.ScreenManager.Game); this.mNewGameButton = new MainMenuButton { Text = "New Game", InactiveFont = this.MainMenuFont, ActiveFont = this.MainMenuFontBold, BlankTexture = lBlankTexture, Position = lCurrentPosition, Size = lButtonSize, IsActive = false, IsEnabled = true, }; this.mNewGameButton.Selected += (s, e) => this.StartNewGame(); lCurrentPosition.Y += lButtonSize.Y + 10; this.mContinueGameButton = new MainMenuButton { Text = "Continue Game", InactiveFont = this.MainMenuFont, ActiveFont = this.MainMenuFontBold, BlankTexture = lBlankTexture, Position = lCurrentPosition, Size = lButtonSize, IsActive = false, IsEnabled = this.PlayerManager.SaveGameExists, }; this.mContinueGameButton.Selected += (s, e) => this.ContinuePreviousGame(); lCurrentPosition.Y += lButtonSize.Y + 10; this.mExitButton = new MainMenuButton { Text = "Exit", InactiveFont = this.MainMenuFont, ActiveFont = this.MainMenuFontBold, BlankTexture = lBlankTexture, Position = lCurrentPosition, Size = lButtonSize, IsActive = false, IsEnabled = this.PlayerManager.SaveGameExists, }; this.mExitButton.Selected += (s, e) => this.ScreenManager.Game.Exit(); this.mButtons = new List<MainMenuButton>(); this.mButtons.Add(this.mNewGameButton); this.mButtons.Add(this.mContinueGameButton); this.mButtons.Add(this.mExitButton); }