Пример #1
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Draws the button "bar" (the color changes based on if the button is being hovered or clicked)
            var color = _baseColor;

            if (_isHovering)
            {
                color = _hoverColor;
            }
            if (_isClicked)
            {
                color = _clickedColor;
            }

            ShapeExtensions.FillRectangle(spriteBatch, Rectangle, color);

            // Draws the text
            if (!string.IsNullOrEmpty(Text))
            {
                var x = (Rectangle.X + (Rectangle.Width / 2)) - (_font.MeasureString(Text).X / 2);
                var y = (Rectangle.Y + (Rectangle.Height / 2)) - (_font.MeasureString(Text).Y / 2);

                spriteBatch.DrawString(_font, Text, new Vector2(x, y + TextTopPadding), TextColor);
            }
        }
Пример #2
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            ShapeExtensions.FillRectangle(spriteBatch, Rectangle, _boxColor);

            if (IsEnabled)
            {
                ShapeExtensions.FillRectangle(spriteBatch,
                                              new Rectangle(Rectangle.X + ((Rectangle.Width - ((int)(_size * 0.6f))) / 2), Rectangle.Y + ((Rectangle.Height - ((int)(_size * 0.6f))) / 2), (int)(_size * 0.6f), (int)(_size * 0.6f)),
                                              _markedColor);
            }
        }
Пример #3
0
        public void Render(double deltaTime)
        {
            var ent             = EntityManager.GetEntiy <GameObject>(EntID);
            var outlineColorCom = ent.GetComponent <ColorValueCom>(OutlineColorAlias);
            var barColorCom     = ent.GetComponent <ColorValueCom>(BarColorAlias);
            var rectPosCom      = ent.GetComponent <IHaveHitBoxCom>(RectPosAlais);
            var timerCom        = ent.GetComponent <TimerCom>(TimerValueAlias);

            var timeRectangle = new Paultangle(rectPosCom.HitBox);

            timeRectangle.Width = (timerCom.Value / timerCom.EndTime) * timeRectangle.Width;

            ShapeExtensions.FillRectangle(SpriteBatch, timeRectangle.ToRectangleF(), barColorCom.Value);

            ShapeExtensions.DrawRectangle(SpriteBatch, rectPosCom.HitBox.ToRectangleF(), outlineColorCom.Value, (float)Thickness);
        }
Пример #4
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (Active)
            {
                ShapeExtensions.FillRectangle(spriteBatch, _bar, _activeBarColor);
            }
            else
            {
                ShapeExtensions.FillRectangle(spriteBatch, _bar, _barColor);
            }

            Renderer.Draw(spriteBatch);

            if (Active)
            {
                Cursor.Draw(spriteBatch);
            }
        }
Пример #5
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Draws the bar and the knob
            var barColor  = _barColor;
            var knobColor = _knobColor;

            if (_isHovering)
            {
                knobColor = _hoverColor;
            }
            if (_isClicked)
            {
                knobColor = _clickedColor;
            }

            ShapeExtensions.FillRectangle(spriteBatch, _barRectangle, barColor);

            ShapeExtensions.FillRectangle(spriteBatch, _knobRectangle, knobColor);
        }