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);
        }
Beispiel #2
0
        /// <summary>
        /// Render the animation.
        /// </summary>
        /// <param name="ScaledSpriteBatch">ScaledSpriteBatch with which the current frame
        /// will be rendered.</param>
        /// <param name="position">The position to draw the current frame.</param>
        /// <param name="scale">Scale factor to apply to the current frame.</param>
        /// <param name="spriteEffect">SpriteEffect to apply to the
        /// current frame.</param>
        public void Draw(ScaledSpriteBatch ScaledSpriteBatch, Vector2 position, float scale, SpriteEffects spriteEffect)
        {
            drawWasAlreadyCalledOnce = true;

            ScaledSpriteBatch.Draw(animatedCharacter, position + Offset,
                                   new Rectangle(frameSize.X * currentFrame.X, frameSize.Y * currentFrame.Y, frameSize.X, frameSize.Y),
                                   Color.White, 0f, Vector2.Zero, scale, spriteEffect, 0);
        }
        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();
        }
        /// <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();
        }
        /// <summary>
        /// Render the animation.
        /// </summary>
        /// <param name="ScaledSpriteBatch">ScaledSpriteBatch with which the current frame
        /// will be rendered.</param>
        /// <param name="position">The position to draw the current frame.</param>
        /// <param name="scale">Scale factor to apply to the current frame.</param>
        /// <param name="spriteEffect">SpriteEffect to apply to the 
        /// current frame.</param>
        public void Draw(ScaledSpriteBatch ScaledSpriteBatch, Vector2 position, float scale, SpriteEffects spriteEffect)
        {
            drawWasAlreadyCalledOnce = true;

            ScaledSpriteBatch.Draw(animatedCharacter, position + Offset,
                new Rectangle(frameSize.X * currentFrame.X, frameSize.Y * currentFrame.Y, frameSize.X, frameSize.Y),
                Color.White, 0f, Vector2.Zero, scale, spriteEffect, 0);
        }