Beispiel #1
0
        /// <summary>
        /// Draws the component.
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Draw(GameTime gameTime)
        {
            if (!gameplayScreen.IsActive)
            {
                base.Draw(gameTime);
                return;
            }
            if (!isAppearAtCountDown && !gameplayScreen.IsStarted)
            {
                base.Draw(gameTime);
                return;
            }

            float rotation;

            // Determine the orientation of the component
            if (scoreBarOrientation == ScoreBar.ScoreBarOrientation.Horizontal)
            {
                rotation = 0f;
            }
            else
            {
                rotation = 1.57f;
            }

            scaledSpriteBatch.Begin();

            // Draws the background of the score bar
            scaledSpriteBatch.Draw(backgroundTexture, new Rectangle((int)Position.X, (int)Position.Y, width, height),
                                   null, ScoreBarColor, rotation, new Vector2(0, 0), SpriteEffects.None, 0);

            // Gets the margin from the border
            decimal spaceFromBorder = GetSpaceFromBorder();

            spaceFromBorder += 4;
            Texture2D coloredTexture = GetTextureByCurrentValue(currentValue);

            if (scoreBarOrientation == ScoreBarOrientation.Horizontal)
            {
                scaledSpriteBatch.Draw(coloredTexture, new Rectangle((int)Position.X + 2, (int)Position.Y + 2,
                                                                     width - (int)spaceFromBorder, height - 4), null, Color.White, rotation, new Vector2(0, 0),
                                       SpriteEffects.None, 0);
            }
            else
            {
                scaledSpriteBatch.Draw(coloredTexture, new Rectangle((int)Position.X + 2 - height,
                                                                     (int)Position.Y + width + -2, width - (int)spaceFromBorder, height - 4), null, ScoreBarColor,
                                       -rotation, new Vector2(0, 0), SpriteEffects.None, 0);
            }

            scaledSpriteBatch.End();

            base.Draw(gameTime);
        }
        /// <summary>
        /// Helper draws a translucent black fullscreen sprite, used for fading
        /// screens in and out, and for darkening the background behind popups.
        /// </summary>
        public void FadeBackBufferToBlack(float alpha)
        {
            Viewport viewport = GraphicsDevice.Viewport;

            spriteBatch.Begin();

            spriteBatch.Draw(blankTexture,
                             new Rectangle(0, 0, viewport.Width, viewport.Height),
                             Color.Black * alpha);

            spriteBatch.End();
        }
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            scaledSpriteBatch.Begin();

            if (DrawBounds)
            {
                scaledSpriteBatch.Draw(borderTexture, Bounds, Color.Red);
            }

            if (DrawCollisionArea)
            {
                scaledSpriteBatch.Draw(borderTexture, CentralCollisionArea, Color.Yellow);
            }

            scaledSpriteBatch.End();
        }