/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); switch (CurrentGameState) { case GameState.MainMenu: spriteBatch.Begin(); spriteBatch.Draw(Content.Load <Texture2D>("Background/MainMenuBKAgile"), new Rectangle(0, 0, screenWidth, screenHeight), Color.White); foreach (cButton b in mainMenuButtons) { b.Draw(spriteBatch); } spriteBatch.End(); break; case GameState.Playing: //Main Game Draw Pass spriteBatch.Begin(); spriteBatch.Draw(Content.Load <Texture2D>("Background/MapBackground"), new Rectangle(0, 0, screenWidth, screenHeight), Color.White); #region Draw Map //Map map.Draw(spriteBatch); #endregion #region Draw Test /* foreach(CollisionTiles t in map.CollisionTiles) * { * DrawBorders(t.Rectangle, 1, Color.Cyan); * } */ #endregion #region Draw Player player.Draw(spriteBatch); #endregion foreach (Enemy j in enemies) { j.Draw(spriteBatch); } foreach (Level l in levels) { l.Draw(spriteBatch); } #region Bullet Draw foreach (BulletM b in bullets) { b.Draw(spriteBatch); } #endregion #region Draw Pickups foreach (PickUp a in pickUps) { a.Draw(spriteBatch); } spriteBatch.End(); #endregion #region Armour Bar //This is your armour pass aBatch.Begin(); aBatch.Draw(aArmourBar, new Rectangle(this.Window.ClientBounds.Width / 2 - aArmourBar.Width / 2, 30, aArmourBar.Width, 44), new Rectangle(0, 45, aArmourBar.Width, 44), Color.Gray); aBatch.Draw(aArmourBar, new Rectangle(this.Window.ClientBounds.Width / 2 - aArmourBar.Width / 2, 30, (int)(aArmourBar.Width * ((double)aCurrentArmour / 100)), 44), new Rectangle(0, 45, aArmourBar.Width, 44), Color.LightBlue); aBatch.Draw(aArmourBar, new Rectangle(this.Window.ClientBounds.Width / 2 - aArmourBar.Width / 2, 30, aArmourBar.Width, 44), new Rectangle(0, 0, aArmourBar.Width, 44), Color.White); aBatch.End(); #endregion #region HUD Elements //This is your HUD pass spriteBatch.Begin(); if (player.HasPickedUp) { if (player.WEquipped) { spriteBatch.Draw(weaponIcon, wpnIconRect, Color.White); } else { spriteBatch.Draw(weaponIcon, wpnIconRect, Color.Black); } } switch (aCurrentArmour) { case 0: spriteBatch.Draw(armourIcons[0], armIconRect, Color.Black); break; case 25: spriteBatch.Draw(armourIcons[0], armIconRect, Color.White); break; case 50: spriteBatch.Draw(armourIcons[2], armIconRect, Color.White); break; case 75: spriteBatch.Draw(armourIcons[3], armIconRect, Color.White); break; case 100: spriteBatch.Draw(armourIcons[4], armIconRect, Color.White); break; } spriteBatch.End(); base.Draw(gameTime); break; #endregion case GameState.Playing2: //Main Game Draw Pass spriteBatch.Begin(); spriteBatch.Draw(Content.Load <Texture2D>("Background/MapBackground"), new Rectangle(0, 0, screenWidth, screenHeight), Color.White); #region Draw Map //Map map.Draw(spriteBatch); #endregion #region Draw Test /* foreach(CollisionTiles t in map.CollisionTiles) * { * DrawBorders(t.Rectangle, 1, Color.Cyan); * } */ #endregion #region Draw Player player.Draw(spriteBatch); #endregion foreach (Enemy j in enemies) { j.Draw(spriteBatch); } foreach (Level l in levels) { l.Draw(spriteBatch); } #region Bullet Draw foreach (BulletM b in bullets) { b.Draw(spriteBatch); } #endregion #region Draw Pickups foreach (PickUp a in pickUps) { a.Draw(spriteBatch); } spriteBatch.End(); #endregion #region Armour Bar //This is your armour pass aBatch.Begin(); aBatch.Draw(aArmourBar, new Rectangle(this.Window.ClientBounds.Width / 2 - aArmourBar.Width / 2, 30, aArmourBar.Width, 44), new Rectangle(0, 45, aArmourBar.Width, 44), Color.Gray); aBatch.Draw(aArmourBar, new Rectangle(this.Window.ClientBounds.Width / 2 - aArmourBar.Width / 2, 30, (int)(aArmourBar.Width * ((double)aCurrentArmour / 100)), 44), new Rectangle(0, 45, aArmourBar.Width, 44), Color.LightBlue); aBatch.Draw(aArmourBar, new Rectangle(this.Window.ClientBounds.Width / 2 - aArmourBar.Width / 2, 30, aArmourBar.Width, 44), new Rectangle(0, 0, aArmourBar.Width, 44), Color.White); aBatch.End(); #endregion #region HUD Elements //This is your HUD pass spriteBatch.Begin(); if (player.HasPickedUp) { if (player.WEquipped) { spriteBatch.Draw(weaponIcon, wpnIconRect, Color.White); } else { spriteBatch.Draw(weaponIcon, wpnIconRect, Color.Black); } } switch (aCurrentArmour) { case 0: spriteBatch.Draw(armourIcons[0], armIconRect, Color.Black); break; case 25: spriteBatch.Draw(armourIcons[0], armIconRect, Color.White); break; case 50: spriteBatch.Draw(armourIcons[2], armIconRect, Color.White); break; case 75: spriteBatch.Draw(armourIcons[3], armIconRect, Color.White); break; case 100: spriteBatch.Draw(armourIcons[4], armIconRect, Color.White); break; } spriteBatch.End(); base.Draw(gameTime); break; #endregion case GameState.Quiting: spriteBatch.Begin(); spriteBatch.Draw(Content.Load <Texture2D>("Background/MainMenuBKAgile"), new Rectangle(0, 0, screenWidth, screenHeight), Color.White); foreach (cButton b in quitButtons) { b.Draw(spriteBatch); } spriteBatch.End(); break; case GameState.ConfirmQuiting: spriteBatch.Begin(); spriteBatch.Draw(Content.Load <Texture2D>("Background/MainMenuBKAgile"), new Rectangle(0, 0, screenWidth, screenHeight), Color.White); foreach (cButton b in quitButtons) { b.Draw(spriteBatch); } spriteBatch.End(); break; } }