예제 #1
0
        /// <summary>
        /// Draws the heads up display to the screen.
        /// </summary>
        public void Draw()
        {
            Sprite.Draw(this.powerUpBox, this.powerUpPosition, 0.0f);
            switch (this.ActivePowerUp)
            {
            case PowerUpType.Invincibility:
                Sprite.Draw(this.invincible, this.powerUpPosition, 0.0f);
                break;

            case PowerUpType.Health:
                Sprite.Draw(this.healthPowerUp, this.powerUpPosition, 0.0f);
                break;

            case PowerUpType.Jump:
                Sprite.Draw(this.jump, this.powerUpPosition, 0.0f);
                break;

            case PowerUpType.Speed:
                Sprite.Draw(this.speed, this.powerUpPosition, 0.0f);
                break;

            default:
                break;
            }

            this.score.SetText(this.Score.ToString("D6"));
            this.health.SetText(this.HealthPercentage.ToString("N0") + "%");
            RenderableText.Draw(this.scoreText, this.scoreTextPosition, 0.0f, this.textColour);
            RenderableText.Draw(this.score, this.scorePosition, 0.0f, this.textColour);
            RenderableText.Draw(this.healthText, this.healthTextPosition, 0.0f, this.textColour);
            RenderableText.Draw(this.health, this.healthPosition, 0.0f, this.textColour);
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeadsUpDisplay"/> class.
 /// </summary>
 /// <param name="displaySize">The size of the display area.</param>
 public HeadsUpDisplay(Vector2 displaySize)
 {
     this.displaySize        = displaySize;
     this.powerUpBox         = new Sprite();
     this.invincible         = new Sprite();
     this.healthPowerUp      = new Sprite();
     this.jump               = new Sprite();
     this.speed              = new Sprite();
     this.scoreText          = new RenderableText();
     this.score              = new RenderableText();
     this.healthText         = new RenderableText();
     this.health             = new RenderableText();
     this.ActivePowerUp      = PowerUpType.None;
     this.Score              = 0;
     this.HealthPercentage   = 100.0f;
     this.powerUpPosition    = new Vector2(this.displaySize.X * 0.5f, this.displaySize.Y * 0.1f);
     this.scoreTextPosition  = new Vector2(this.displaySize.X * 0.572f, this.displaySize.Y * 0.075f);
     this.scorePosition      = new Vector2(this.displaySize.X * 0.648f, this.displaySize.Y * 0.075f);
     this.healthTextPosition = new Vector2(this.displaySize.X * 0.355f, this.displaySize.Y * 0.075f);
     this.healthPosition     = new Vector2(this.displaySize.X * 0.43f, this.displaySize.Y * 0.075f);
     this.textColour         = new Color(50, 50, 50);
 }
예제 #3
0
 /// <summary>
 /// Draws text to the screen.
 /// </summary>
 /// <param name="renderableText">The text to draw.</param>
 /// <param name="position">The position to draw the text at.</param>
 /// <param name="rotation">The rotation of the text.</param>
 public static void Draw(RenderableText renderableText, Vector2 position, float rotation)
 {
     renderableText.spriteBatch.DrawString(renderableText.font, renderableText.text, position, renderableText.Colour, rotation, renderableText.origin, 1.0f, SpriteEffects.None, 1.0f);
 }
예제 #4
0
 /// <summary>
 /// Draws text to the screen.
 /// </summary>
 /// <param name="renderableText">The text to draw.</param>
 /// <param name="position">The position to draw the text at.</param>
 /// <param name="rotation">The rotation of the text.</param>
 /// <param name="colour">The colour to draw the text in.</param>
 /// <param name="scale">The scale to draw the text at.</param>
 /// <param name="effect">The effect to apply to the text before drawing.</param>
 /// <param name="layerDepth">The layer depth of the text.</param>
 public static void Draw(RenderableText renderableText, Vector2 position, float rotation, Color colour, float scale = 1.0f, SpriteEffects effect = SpriteEffects.None, float layerDepth = 1.0f)
 {
     renderableText.spriteBatch.DrawString(renderableText.font, renderableText.text, position, colour, rotation, renderableText.origin, scale, effect, layerDepth);
 }
예제 #5
0
 /// <summary>
 /// Draws text to the screen.
 /// </summary>
 /// <param name="renderableText">The text to draw.</param>
 /// <param name="position">The position to draw the text at.</param>
 /// <param name="rotation">The rotation of the text.</param>
 /// <param name="colour">The colour to draw the text in.</param>
 /// <param name="scale">The scale to draw the text at.</param>
 /// <param name="effect">The effect to apply to the text before drawing.</param>
 /// <param name="layerDepth">The layer depth of the text.</param>
 public static void Draw(RenderableText renderableText, Vector2 position, float rotation, Color colour, float scale = 1.0f, SpriteEffects effect = SpriteEffects.None, float layerDepth = 1.0f)
 {
     renderableText.spriteBatch.DrawString(renderableText.font, renderableText.text, position, colour, rotation, renderableText.origin, scale, effect, layerDepth);
 }
예제 #6
0
 /// <summary>
 /// Draws text to the screen.
 /// </summary>
 /// <param name="renderableText">The text to draw.</param>
 /// <param name="position">The position to draw the text at.</param>
 /// <param name="rotation">The rotation of the text.</param>
 public static void Draw(RenderableText renderableText, Vector2 position, float rotation)
 {
     renderableText.spriteBatch.DrawString(renderableText.font, renderableText.text, position, renderableText.Colour, rotation, renderableText.origin, 1.0f, SpriteEffects.None, 1.0f);
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeadsUpDisplay"/> class.
 /// </summary>
 /// <param name="displaySize">The size of the display area.</param>
 public HeadsUpDisplay(Vector2 displaySize)
 {
     this.displaySize = displaySize;
     this.powerUpBox = new Sprite();
     this.invincible = new Sprite();
     this.healthPowerUp = new Sprite();
     this.jump = new Sprite();
     this.speed = new Sprite();
     this.scoreText = new RenderableText();
     this.score = new RenderableText();
     this.healthText = new RenderableText();
     this.health = new RenderableText();
     this.ActivePowerUp = PowerUpType.None;
     this.Score = 0;
     this.HealthPercentage = 100.0f;
     this.powerUpPosition = new Vector2(this.displaySize.X * 0.5f, this.displaySize.Y * 0.1f);
     this.scoreTextPosition = new Vector2(this.displaySize.X * 0.572f, this.displaySize.Y * 0.075f);
     this.scorePosition = new Vector2(this.displaySize.X * 0.648f, this.displaySize.Y * 0.075f);
     this.healthTextPosition = new Vector2(this.displaySize.X * 0.355f, this.displaySize.Y * 0.075f);
     this.healthPosition = new Vector2(this.displaySize.X * 0.43f, this.displaySize.Y * 0.075f);
     this.textColour = new Color(50, 50, 50);
 }