Beispiel #1
0
 /// <summary>
 /// Метод отрисовки объекта
 /// </summary>
 public override void Draw()
 {
     Game.Buffer.Graphics.DrawImage(Img, Pos);
     Rect = new Rectangle(Pos.X, Pos.Y, Img.Size.Width - (int)(Img.Size.Width * 0.2), Img.Size.Height - (int)(Img.Size.Height * 0.2));
     HealthBar.Draw();
     EnergyBar.Draw();
 }
Beispiel #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Draw(GameTime gameTime)
        {
            // Màu nền
            TankWars.GraphicsDevice.Clear(Color.Black);

            // Dùng để vẽ các đối tượng
            SpriteBatch spriteBatch = TankWars.SpriteBatch;

            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend
                              /*, null, null, null, null, Camera.get_transformation(Game.GraphicsDevice)*/);

            // Vẽ Màn chơi
            Map.Draw(gameTime, spriteBatch);

            foreach (PowerIcon power in PowerIconList)
            {
                power.Draw(gameTime, spriteBatch);
            }

            // Vẽ Minimap
            Minimap.Draw(gameTime, spriteBatch);

            // Vẽ cursor người chơi
            Cursor.Draw(gameTime, spriteBatch);

            // Vẽ người chơi
            if (!Player.IsDead)
            {
                Player.Draw(gameTime, spriteBatch);
                Direction.Draw(gameTime, spriteBatch);
                Minimap.DrawDot(Player, Color.Blue, spriteBatch);
            }

            // Vẽ Health Bar
            HealthBar.Draw(Player.HitPoints, Player.MaxHitPoints, spriteBatch);

            // Vẽ Energy Bar
            EnergyBar.Draw(Player.EnergyPoints, Player.MaxEnergyPoints, spriteBatch);

            // Vẽ đạn
            foreach (Ammunition ammunition in AmmunitionList)
            {
                ammunition.Draw(gameTime, spriteBatch);
            }

            // Vẽ các vụ nổ
            foreach (Sprite effect in EffectList)
            {
                effect.Draw(gameTime, spriteBatch);
            }

            // Vẽ Enemy
            foreach (Tank enemy in EnemyList)
            {
                enemy.Draw(gameTime, spriteBatch);
                Minimap.DrawDot(enemy, Color.Red, spriteBatch);
            }

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                TankWars.FadeBackBufferToBlack(alpha);
            }
        }