using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace CarFire { class HUD { Game mGame; SpriteFont HUDfont; public HUD(Game game) { mGame = game; } public void LoadContent(ContentManager contentManager) { HUDfont = contentManager.Load("menuFont"); } /// /// This is called when the game should draw itself. /// /// Used to draw with public void Draw(SpriteBatch spriteBatch) { Color[] playerColors = new Color[4]; playerColors[0] = Color.Red; playerColors[1] = Color.PowderBlue; playerColors[2] = Color.Peru; playerColors[3] = Color.Wheat; for (int i = 0; i < mGame.State.mCharacters.Length; i++ ) { Player player = mGame.State.mCharacters[i]; spriteBatch.DrawString(HUDfont, "Player" + (i+1), new Vector2(640, 10 + 80*i), playerColors[i]); spriteBatch.DrawString(HUDfont, "Health: " + player.Health, new Vector2(640, 30 + 80 * i), playerColors[i]); spriteBatch.DrawString(HUDfont, "Score: " + player.Score, new Vector2(640, 50 + 80 * i), playerColors[i]); } } } }