/// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="game">Associated game object.</param>
        /// <param name="gamePlayScreen">Gameplay screen where the component will be presented.</param>
        public TexturedDrawableGameComponent(Game game, GameplayScreen gamePlayScreen)
            : base(game)
        {
            this.gamePlayScreen = gamePlayScreen;

            scaledSpriteBatch = (ScaledSpriteBatch)game.Services.GetService(typeof(ScaledSpriteBatch));
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="game">Associated game object.</param>
        /// <param name="gamePlayScreen">Gameplay screen where the component will be presented.</param>
        public TexturedDrawableGameComponent(Game game, GameplayScreen gamePlayScreen)
            : base(game)
        {
            this.gamePlayScreen = gamePlayScreen;

            scaledSpriteBatch = (ScaledSpriteBatch)game.Services.GetService(typeof(ScaledSpriteBatch));
        }
Esempio n. 3
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);
        }
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load content belonging to the screen manager.
            ContentManager content = Game.Content;

            spriteBatch = new ScaledSpriteBatch(Game.GraphicsDevice, drawingScale);
            Game.Services.AddService(typeof(ScaledSpriteBatch), spriteBatch);

            font             = content.Load <SpriteFont>("Fonts/MenuFont");
            blankTexture     = content.Load <Texture2D>("Textures/Backgrounds/blank");
            buttonBackground = content.Load <Texture2D>("Textures/Backgrounds/buttonBackground");

            // Tell each of the screens to load their content.
            foreach (GameScreen screen in screens)
            {
                screen.LoadContent();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new score bar instance.
        /// </summary>
        /// <param name="game">The associated game object.</param>
        /// <param name="minValue">The score bar's minimal value.</param>
        /// <param name="maxValue">The score bar's maximal value.</param>
        /// <param name="position">The score bar's position.</param>
        /// <param name="height">The score bar's height.</param>
        /// <param name="width">The score bar's width.</param>
        /// <param name="scoreBarColor">Color to tint the scorebar's background with.</param>
        /// <param name="scoreBarOrientation">The score bar's orientation.</param>
        /// <param name="initialValue">The score bar's initial value.</param>
        /// <param name="screen">Gameplay screen where the score bar will appear.</param>
        /// <param name="isAppearAtCountDown">Whether or not the score bar will appear during the game's initial
        /// countdown phase.</param>
        public ScoreBar(Game game, int minValue, int maxValue, Vector2 position, int height, int width,
                        Color scoreBarColor, ScoreBarOrientation scoreBarOrientation, int initialValue, GameplayScreen screen,
                        bool isAppearAtCountDown)
            : base(game)
        {
            this.MinValue            = minValue;
            this.MaxValue            = maxValue;
            this.Position            = position;
            this.ScoreBarColor       = scoreBarColor;
            this.scoreBarOrientation = scoreBarOrientation;
            this.currentValue        = initialValue;
            this.width               = width;
            this.height              = height;
            this.gameplayScreen      = screen;
            this.isAppearAtCountDown = isAppearAtCountDown;


            scaledSpriteBatch = (ScaledSpriteBatch)Game.Services.GetService(typeof(ScaledSpriteBatch));

            GetSpaceFromBorder();
        }
Esempio n. 6
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);
        }
Esempio n. 7
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="spriteEffect">SpriteEffect to apply to the 
 /// current frame.</param>
 public void Draw(ScaledSpriteBatch ScaledSpriteBatch, Vector2 position, SpriteEffects spriteEffect)
 {
     Draw(ScaledSpriteBatch, position, 1.0f, spriteEffect);
 }
Esempio n. 8
0
        /// <summary>
        /// Creates a new score bar instance.
        /// </summary>
        /// <param name="game">The associated game object.</param>
        /// <param name="minValue">The score bar's minimal value.</param>
        /// <param name="maxValue">The score bar's maximal value.</param>
        /// <param name="position">The score bar's position.</param>
        /// <param name="height">The score bar's height.</param>
        /// <param name="width">The score bar's width.</param>
        /// <param name="scoreBarColor">Color to tint the scorebar's background with.</param>
        /// <param name="scoreBarOrientation">The score bar's orientation.</param>
        /// <param name="initialValue">The score bar's initial value.</param>
        /// <param name="screen">Gameplay screen where the score bar will appear.</param>
        /// <param name="isAppearAtCountDown">Whether or not the score bar will appear during the game's initial
        /// countdown phase.</param>
        public ScoreBar(Game game, int minValue, int maxValue, Vector2 position, int height, int width,
            Color scoreBarColor, ScoreBarOrientation scoreBarOrientation, int initialValue, GameplayScreen screen,
            bool isAppearAtCountDown)
            : base(game)
        {
            this.MinValue = minValue;
            this.MaxValue = maxValue;
            this.Position = position;
            this.ScoreBarColor = scoreBarColor;
            this.scoreBarOrientation = scoreBarOrientation;
            this.currentValue = initialValue;
            this.width = width;
            this.height = height;
            this.gameplayScreen = screen;
            this.isAppearAtCountDown = isAppearAtCountDown;


            scaledSpriteBatch = (ScaledSpriteBatch)Game.Services.GetService(typeof(ScaledSpriteBatch));

            GetSpaceFromBorder();
        }
Esempio n. 9
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load content belonging to the screen manager.
            ContentManager content = Game.Content;

            spriteBatch = new ScaledSpriteBatch(Game.GraphicsDevice, drawingScale);
            Game.Services.AddService(typeof(ScaledSpriteBatch), spriteBatch); 

            font = content.Load<SpriteFont>("Fonts/MenuFont");
            blankTexture = content.Load<Texture2D>("Textures/Backgrounds/blank");
            buttonBackground = content.Load<Texture2D>("Textures/Backgrounds/buttonBackground");

            // Tell each of the screens to load their content.
            foreach (GameScreen screen in screens)
            {
                screen.LoadContent();
            }
        }
Esempio n. 10
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="spriteEffect">SpriteEffect to apply to the
 /// current frame.</param>
 public void Draw(ScaledSpriteBatch ScaledSpriteBatch, Vector2 position, SpriteEffects spriteEffect)
 {
     Draw(ScaledSpriteBatch, position, 1.0f, spriteEffect);
 }