Draw() public method

Advances the time position and draws the current frame of the animation.
public Draw ( GameTime gameTime, SpriteBatch spriteBatch, Vector2 position, SpriteEffects spriteEffects ) : void
gameTime Microsoft.Xna.Framework.GameTime
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
position Vector2
spriteEffects SpriteEffects
return void
Exemplo n.º 1
0
        /// <summary>
        /// Draws the animated enemy.
        /// </summary>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Stop running when the game is paused, before turning around, or if the possessing player is idle.
            if (!Level.Player.IsAlive ||
                Level.ReachedExit ||
                Level.TimeRemaining == TimeSpan.Zero ||
                waitTime > 0 || this.direction == FaceDirection.Idle)
            {
                if (isNearest || possessed)
                {
                    sprite.PlayAnimation(evilIdleAnimation);
                    spriteGlow.PlayAnimation(evilIdleAnimationGlow);
                }
                else
                {
                    sprite.PlayAnimation(idleAnimation);
                }
            }
            else
            {
                if (isNearest || possessed)
                {
                    sprite.PlayAnimation(evilRunAnimation);
                    spriteGlow.PlayAnimation(evilRunAnimationGlow);
                }
                else
                {
                    sprite.PlayAnimation(runAnimation);
                }
            }

            if (!player.IsOnGround && monsterType == MonsterType.Lantern)
            {
                sprite.PlayAnimation(evilJumpAnimation);
            }

            // Draw facing the way the enemy is moving.
            SpriteEffects flip = direction > 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            if (isNearest)
            {
                spriteGlow.Draw(gameTime, spriteBatch, Position, flip);
                sprite.Draw(gameTime, spriteBatch, Position, flip);
            }
            else
            {
                sprite.Draw(gameTime, spriteBatch, Position, flip);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Draws the knife
 /// </summary>
 public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     if (canAttack || attacking)
     {
         sprite.Draw(gameTime, spriteBatch, Position, Flip);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Draws the animated player.
        /// </summary>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            Vector2 drawPosn = GetDrawPosn();

            sprite.Draw(spriteBatch, drawPosn);
            spriteBatch.Draw(BoundImage, new Vector2(BoundingRectangle.X, BoundingRectangle.Y), Color.White);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Draws the animated enemy.
        /// </summary>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
                        #if ZUNE
            Vector2 screenOffset = new Vector2(16, 80);
                        #elif IPHONE
            Vector2 screenOffset = new Vector2(40, 80);
                        #else
            Vector2 screenOffset = new Vector2(0, 0);
            #endif

            // Stop running when the game is paused or before turning around.
            if (!Level.Player.IsAlive ||
                Level.ReachedExit ||
                Level.TimeRemaining == TimeSpan.Zero ||
                waitTime > 0)
            {
                sprite.PlayAnimation(idleAnimation);
            }
            else
            {
                sprite.PlayAnimation(runAnimation);
            }


            // Draw facing the way the enemy is moving.
            SpriteEffects flip = direction > 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
            sprite.Draw(gameTime, spriteBatch, Position + screenOffset, flip);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Draws the animated enemy.
        /// </summary>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Stop running when the game is paused or before turning around.
            if (!IsAlive)
            {
                sprite.PlayAnimation(dieAnimation);
            }
            else if (!Level.Player.IsAlive ||
                     Level.ReachedExit ||
                     Level.TimeRemaining == TimeSpan.Zero ||
                     waitTime > 0)
            {
                sprite.PlayAnimation(idleAnimation);
            }
            else
            {
                sprite.PlayAnimation(runAnimation);
            }



            // Draw facing the way the enemy is moving.
            SpriteEffects flip = direction > 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            sprite.Draw(gameTime, spriteBatch, Position, flip, Color.White);
        }
Exemplo n.º 6
0
        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            var enemyScreenLocation = new Vector2();

            enemyScreenLocation.X = MapLocation.X - Camera.Location.X;
            enemyScreenLocation.Y = MapLocation.Y - Camera.Location.Y;

            sprite.Draw(gameTime, spriteBatch, enemyScreenLocation + new Vector2(Constants.SpriteWidth / 2, Constants.SpriteHeight / 2), SpriteEffects.None, 0);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Draws the gun
        /// </summary>
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Draw that sprite.
            sprite.Draw(gameTime, spriteBatch, Position, Flip);

            if (isShooting)
            {
                Vector2 offset = (Flip == SpriteEffects.None) ? new Vector2(32, 2) : new Vector2(-32, 2);
                muzzle.Draw(gameTime, spriteBatch, Position + offset, Flip);
            }
        }
Exemplo n.º 8
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (attacking || charging)
            {
                sprite.Draw(gameTime, spriteBatch, this.position, Flip);
            }

            explosion.Draw(gameTime, spriteBatch);
            //basicEffect.CurrentTechnique.Passes[0].Apply();
            //game.ScreenManager.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, 1);
        }
Exemplo n.º 9
0
        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            var playerScreenLocation = new Vector2();

            playerScreenLocation.X = MapLocation.X - Camera.Location.X;
            playerScreenLocation.Y = MapLocation.Y - Camera.Location.Y;

            if (IsAttacking)
            {
                swordAnimator.Draw(gameTime, spriteBatch, getSwordLocation(playerScreenLocation), SpriteEffects.None, Angle);
            }
            sprite.Draw(gameTime, spriteBatch, playerScreenLocation + new Vector2(Constants.SpriteWidth / 2, Constants.SpriteHeight / 2), SpriteEffects.None, Angle);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Draws the animated player.
        /// </summary>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Flip the sprite to face the way we are moving.
            if (Velocity.X > 0)
            {
                flip = SpriteEffects.FlipHorizontally;
            }
            else if (Velocity.X < 0)
            {
                flip = SpriteEffects.None;
            }

            // Draw that sprite.
            sprite.Draw(gameTime, spriteBatch, Position, flip);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Draws the gun
        /// </summary>
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Draw that sprite.
            sprite.Draw(gameTime, spriteBatch, Position, Flip);

            if (isShooting)
            {
                Vector2 offset = (Flip == SpriteEffects.None) ? new Vector2(12, 0) : new Vector2(-12, 0);
                muzzle.Draw(gameTime, spriteBatch, Position + offset, Flip);
            }

            // Draw call for bullets
            foreach (HandgunBullet bullet in _bullets)
            {
                bullet.Draw(gameTime, spriteBatch);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Draws the animated player.
        /// </summary>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Flip the sprite to face the way we are moving.
            //if (Velocity.X > 0)
            //    flip = SpriteEffects.FlipHorizontally;
            //else if (Velocity.X < 0)
            //    flip = SpriteEffects.None;

            // Draw that sprite.
            //sprite.Draw(gameTime, spriteBatch, Position, flip);

            int localBoundsWidth = 24;
            //int localBoundsHeight = 52;
            int     rendX    = (int)position.X - localBoundsWidth / 2;
            int     rendY    = (int)position.Y - 2 * (int)Tile.Size.Y;
            Vector2 renderer = new Vector2(rendX, rendY);

            sprite.Draw(spriteBatch, renderer);
            spriteBatch.Draw(BoundImage, new Vector2(BoundingRectangle.X, BoundingRectangle.Y), Color.White);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Draws the animated player.
        /// </summary>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Flip the sprite to face the way we are moving.
            if (Velocity.X > 0)
            {
                flip = SpriteEffects.FlipHorizontally;
            }
            else if (Velocity.X < 0)
            {
                flip = SpriteEffects.None;
            }

            // Calculate a tint color based on power up state.
            Color color = Color.White;

            if (IsPoweredUp)
            {
                float t = ((float)gameTime.TotalGameTime.TotalSeconds + powerUpTime / MaxPowerUpTime) * 20.0f;

                int colorIndex = (int)t % poweredUpColors.Length;
                color = poweredUpColors[colorIndex];
            }
            else if (!IsPoweredDown)
            {
                color = Color.White;
            }

            if (IsPoweredDown)
            {
                float t          = ((float)gameTime.TotalGameTime.TotalSeconds + powerDownTime / MaxPowerDownTime) * 20.0f;
                int   colorIndex = (int)t % poweredDownColors.Length;
                color = poweredDownColors[colorIndex];
            }
            else if (!IsPoweredUp)
            {
                color = Color.White;
            }

            // Draw that sprite.
            sprite.Draw(gameTime, spriteBatch, Position, flip, color);//, color);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Draws the animated player.
        /// </summary>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
                        #if ZUNE
            Vector2 screenOffset = new Vector2(16, 80);
                        #elif IPHONE
            Vector2 screenOffset = new Vector2(40, 80);
                        #else
            Vector2 screenOffset = new Vector2(0, 0);
            #endif

            // Flip the sprite to face the way we are moving.
            if (Velocity.X > 0)
            {
                flip = SpriteEffects.FlipHorizontally;
            }
            else if (Velocity.X < 0)
            {
                flip = SpriteEffects.None;
            }

            // Draw that sprite.
            sprite.Draw(gameTime, spriteBatch, Position + screenOffset, flip);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Draws the animated player.
        /// </summary>
        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Draw player + ghosts
            for (int i = 0; i < PlayerPositions.Count; i++)
            {
                // Flip the sprite to face the way we are moving.
                if (PlayerVelocities[i].X > 0)
                {
                    flips[i] = true;
                }
                else if (PlayerVelocities[i].X < 0)
                {
                    flips[i] = false;
                }

                // because animation player is a struct, which is copied by value
                // when access in a collection, we have to do this or draw will
                // modify the value without updating the one in the collection

                AnimationPlayer sprite = sprites[i];
                sprite.Draw(gameTime, spriteBatch, playerPositions[i], flips[i] ? SpriteEffects.FlipHorizontally : SpriteEffects.None, i > 0);
                sprites[i] = sprite;
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Draws the animated player.
        /// </summary>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (!IsRespawnable)
            {
                return;
            }

            // Flip the sprite to face the way we are moving.
            if (Velocity.X > 0)
            {
                flip = SpriteEffects.None;
            }
            else if (Velocity.X < 0)
            {
                flip = SpriteEffects.FlipHorizontally;
            }

            // Draw that sprite.
            Color newColor = Color.White;

            if (pulseRed)
            {
                Color  spriteColor = Color.Red;
                double speed       = 30.0;
                double pulseCycle  = Math.Sin(gameTime.TotalGameTime.TotalSeconds * speed) / 2.0 + .5;
                byte   range       = 100;

                byte r = (byte)MathHelper.Clamp(MathHelper.Lerp((float)(spriteColor.R - range), (float)(spriteColor.R + range), (float)pulseCycle), 0, 255);
                byte g = (byte)MathHelper.Clamp(MathHelper.Lerp((float)(spriteColor.G - range), (float)(spriteColor.G + range), (float)pulseCycle), 0, 255);
                byte b = (byte)MathHelper.Clamp(MathHelper.Lerp((float)(spriteColor.B - range), (float)(spriteColor.B + range), (float)pulseCycle), 0, 255);

                newColor.R = r;
                newColor.G = g;
                newColor.B = b;
            }

            // spriteBatch.DrawString(font, Position.X.ToString(), position, Color.White);
            sprite.Draw(gameTime, spriteBatch, Position, flip, newColor);

            // Draw the gun if not rolling
            if (isAlive)
            {
                if (!isRolling)
                {
                    weapon.Draw(gameTime, spriteBatch);
                }
                m_bomb.Draw(gameTime, spriteBatch);
            }


            //if the player is offscreen, reset
            // Calculate the visible range of tiles
            int left  = (int)Math.Floor(level.CurrentLevel.Camera.CameraPosition / Tile.Width);
            int right = left + spriteBatch.GraphicsDevice.Viewport.Width / Tile.Width;

            right = Math.Min(right, level.CurrentLevel.Width - 1);
            Vector2 rightEdge = new Vector2(right, 0.0f) * Tile.Size;
            Vector2 leftEdge  = new Vector2(left, 0.0f) * Tile.Size;

            if (position.X < leftEdge.X - (3 * Tile.Width) || position.X > rightEdge.X + (3 * Tile.Width))
            {
                level.CurrentLevel.StartNewLife(this, false);
            }
        }
Exemplo n.º 17
0
 public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     sprite.Draw(gameTime, spriteBatch, Position, SpriteEffects.None);
 }