Ejemplo n.º 1
0
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            // if the enemy is taking damage and is alive then they turn red
            if (takingDamage && isAlive)
            {
                switch (eState.ToString())
                {
                case "WalkLeft":
                    spriteBatch.Draw(enemySprite, new Vector2((int)location.X, (int)location.Y), new Rectangle(ENEMY_WIDTH * currentFrame, 0, ENEMY_WIDTH, ENEMY_HEIGHT), Color.Red, 0, Vector2.Zero, (float)0.5, SpriteEffects.None, 0);
                    break;

                case "WalkRight":
                    spriteBatch.Draw(enemySprite, new Vector2((int)location.X, (int)location.Y), new Rectangle(ENEMY_WIDTH * currentFrame, 0, ENEMY_WIDTH, ENEMY_HEIGHT), Color.Red, 0, Vector2.Zero, (float)0.5, SpriteEffects.FlipHorizontally, 0);
                    break;

                case "FaceLeft":
                    spriteBatch.Draw(enemySprite, new Vector2((int)location.X, (int)location.Y), new Rectangle(0, 0, ENEMY_WIDTH, ENEMY_HEIGHT), Color.Red, 0, Vector2.Zero, (float)0.5, SpriteEffects.None, 0);
                    break;

                case "FaceRight":
                    spriteBatch.Draw(enemySprite, new Vector2((int)location.X, (int)location.Y), new Rectangle(0, 0, ENEMY_WIDTH, ENEMY_HEIGHT), Color.Red, 0, Vector2.Zero, (float)0.5, SpriteEffects.FlipHorizontally, 0);
                    break;
                }
                takingDamage = false;
            }
            // if the enemy is not taking damage and is alive then draw them normally
            else if (isAlive)
            {
                switch (eState.ToString())
                {
                case "WalkLeft":
                    spriteBatch.Draw(enemySprite, new Vector2((int)location.X, (int)location.Y), new Rectangle(ENEMY_WIDTH * currentFrame, 0, ENEMY_WIDTH, ENEMY_HEIGHT), Color.White, 0, Vector2.Zero, (float)0.5, SpriteEffects.None, 0);
                    break;

                case "WalkRight":
                    spriteBatch.Draw(enemySprite, new Vector2((int)location.X, (int)location.Y), new Rectangle(ENEMY_WIDTH * currentFrame, 0, ENEMY_WIDTH, ENEMY_HEIGHT), Color.White, 0, Vector2.Zero, (float)0.5, SpriteEffects.FlipHorizontally, 0);
                    break;

                case "FaceLeft":
                    spriteBatch.Draw(enemySprite, new Vector2((int)location.X, (int)location.Y), new Rectangle(0, 0, ENEMY_WIDTH, ENEMY_HEIGHT), Color.White, 0, Vector2.Zero, (float)0.5, SpriteEffects.None, 0);
                    break;

                case "FaceRight":
                    spriteBatch.Draw(enemySprite, new Vector2((int)location.X, (int)location.Y), new Rectangle(0, 0, ENEMY_WIDTH, ENEMY_HEIGHT), Color.White, 0, Vector2.Zero, (float)0.5, SpriteEffects.FlipHorizontally, 0);
                    break;
                }
            }
        }