コード例 #1
0
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            SpriteFrame spriteFrame = GetSpriteFrame();
            int         x           = Position.X - spriteFrame.Coordinates.Width / 2;
            int         y           = Position.Y - spriteFrame.Coordinates.Height / 2;

            spriteBatch.Draw(spriteFrame.Texture, new Rectangle(x, y, spriteFrame.Coordinates.Width, spriteFrame.Coordinates.Height), spriteFrame.Coordinates, Color.White, 0, Vector2.Zero, SpriteEffects.None, GetZOrder());

            if (this is AbstractWall)
            {
                return;
            }

            if (TsGame.DebugEnabled)
            {
                SpriteHelper.DrawRectangle(spriteBatch, new Rectangle(x, y, spriteFrame.Coordinates.Width, spriteFrame.Coordinates.Height), Color.White, ZOrder.Debug);
                SpriteHelper.DrawPoint(spriteBatch, Position, Color.White, ZOrder.Debug);
            }

            int   maxHealthBarWidth = spriteFrame.Coordinates.Width / 2;
            float healthFraction    = (float)Health / MaxHealth;
            int   healthBarWidth    = Math.Max(1, (int)(healthFraction * (maxHealthBarWidth - 2)));
            Color barColor          = healthFraction > 0.5 ? Color.LimeGreen : healthFraction > 0.25 ? Color.Gold : Color.Red;

            spriteBatch.Draw(Sprites.None.Texture, new Rectangle(x + maxHealthBarWidth / 2, y + HealthBarOffset, maxHealthBarWidth, 4), new Rectangle(0, 0, 1, 1), Color.Black, 0, Vector2.Zero, SpriteEffects.None, ZOrder.HealthBarsBackground);
            spriteBatch.Draw(Sprites.None.Texture, new Rectangle(x + maxHealthBarWidth / 2 + 1, y + HealthBarOffset + 1, healthBarWidth, 2), new Rectangle(0, 0, 1, 1), barColor, 0, Vector2.Zero, SpriteEffects.None, ZOrder.HealthBars);
        }
コード例 #2
0
 public override void Draw(SpriteBatch sb)
 {
     if (drawing)
     {
         SpriteHelper.DrawRectangle(sb, GetPixelDragArea().intRectangle, new Color(100, 100, 255, 100));
     }
 }
コード例 #3
0
 internal void Draw(SpriteBatch sb)
 {
     if (Active)
     {
         SpriteHelper.DrawRectangle(sb, drawRectangle, Color.Orange);
     }
     else if (Toolbox.DEBUG_MODE)
     {
         SpriteHelper.DrawRectangle(sb, drawRectangle, Color.Gray);
     }
 }