Exemplo n.º 1
0
 public BonusOverlay(BonusAction action)
 {
     bonusEntryDirection = DisplayDirection.Enter;
     bonusEntryPosAdjustment = Vector2.Zero;
     bonusEntryTimeIn = AssaultWingCore.Instance.DataEngine.ArenaTotalTime;
     bonusActionData = action;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Draws the overlay graphics component using the guarantee that the
        /// graphics device's viewport is set to the exact area needed by the component.
        /// </summary>
        /// <param name="spriteBatch">The sprite batch to use. <c>Begin</c> is assumed
        /// to have been called and <c>End</c> is assumed to be called after this
        /// method returns.</param>
        private void DrawBonusBox(SpriteBatch spriteBatch, Vector2 bonusPos, BonusAction bonusAction)
        {
            // Draw bonus box background.
            Vector2 backgroundOrigin = new Vector2(0, _bonusBackgroundTexture.Height) / 2;
            spriteBatch.Draw(_bonusBackgroundTexture,
                bonusPos, null, Color.White, 0, backgroundOrigin, 1, SpriteEffects.None, 0);

            // Draw bonus icon.
            var iconPos = bonusPos - backgroundOrigin + new Vector2(133, 9);
            var icon = _player.Game.Content.Load<Texture2D>(bonusAction.BonusIconName);
            spriteBatch.Draw(icon, iconPos, null, _player.Color, 0, Vector2.Zero, 1, SpriteEffects.None, 0);

            // Draw bonus duration meter.
            var duration = (bonusAction.EndTime - _player.Game.DataEngine.ArenaTotalTime).Divide(bonusAction.Duration);
            int durationHeight = (int)Math.Round(duration * _bonusDurationTexture.Height);
            int durationY = _bonusDurationTexture.Height - durationHeight;
            var durationClip = new Rectangle(0, durationY, _bonusDurationTexture.Width, durationHeight);
            var durationPos = bonusPos - backgroundOrigin + new Vector2(14, 8 + durationY);
            spriteBatch.Draw(_bonusDurationTexture,
                durationPos, durationClip, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);

            // Draw bonus text.
            // Round coordinates for beautiful text.
            var bonusText = bonusAction.BonusText;
            var textSize = _bonusFont.MeasureString(bonusText);
            var textPos = bonusPos - backgroundOrigin + new Vector2(32, 25.5f - textSize.Y / 2);
            spriteBatch.DrawString(_bonusFont, bonusText, textPos.Round(), Color.White);
        }