// ***Draw() overload*** /// <summary> /// Draws final score and level information, and instruction text. /// </summary> /// <param name="spriteBatch"> /// The SpriteBatch object used to draw with. /// </param> /// <param name="scoreCounter"> /// The ScoreCounter object. /// </param> /// <param name="levelCounter"> /// The LevelCounter object. /// </param> public void Draw(SpriteBatch spriteBatch, ScoreCounter scoreCounter, LevelCounter levelCounter) { spriteBatch.DrawString( subtextFont, "Score: " + scoreCounter.Value + Environment.NewLine + "Level " + levelCounter.Value + Environment.NewLine + Environment.NewLine + "Press ENTER to restart.", subtextPosition, Color.White); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // TODO: use this.Content to load your game content here // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); wall = Content.Load <Texture2D>("greySquare"); playerArrow = Content.Load <Texture2D>("greySquare"); whiteSquare = Content.Load <Texture2D>("whiteSquare"); verdanaBold20 = Content.Load <SpriteFont>("verdanaBold20"); verdanaBold16 = Content.Load <SpriteFont>("verdanaBold16"); verdana12 = Content.Load <SpriteFont>("verdana12"); verdanaSmall = Content.Load <SpriteFont>("verdanaSmall"); player = new Player(playerArrow); startScreen = new StartScreen(verdanaBold20, verdana12, verdanaSmall, whiteSquare, whiteSquare); pregameScreen = new PregameScreen(verdana12, wall); hiScoreNameEntryScreen = new HiScoreNameEntryScreen(verdanaBold16, verdana12, whiteSquare, whiteSquare, whiteSquare); gameOverScreen = new GameOverScreen(verdanaBold20, verdana12, wall, whiteSquare); leaderboardScreen = new LeaderboardScreen(verdanaBold20, verdanaBold16, verdana12, whiteSquare, whiteSquare); scoreCounter = new ScoreCounter(verdana12); levelCounter = new LevelCounter(verdana12); leaderboard = new Leaderboard(); levelUpAnimation = new LevelUpAnimation(verdana12); // Subscribing applicable methods to both event handlers levelCounter.LevelUpAction += player.LevelUp; levelCounter.LevelUpAction += wallManager.LevelUp; ResetAction += levelCounter.Reset; ResetAction += scoreCounter.Reset; ResetAction += player.Reset; // Initialise leaderboard array. leaderboard.LoadScores(); // Initialise the start screen's "live" background. // This must be done here to avoid an exception being thrown, // because the start screen is loaded upon startup. wallManager.ResetMenu(wall); }