示例#1
0
        protected override void Draw(DemoTime time)
        {
            base.Draw(time);

            RenderTarget2D.Clear(Color.White);

            RenderTarget2D.DrawText("Hello World using DirectWrite!", TextFormat, ClientRectangle, SceneColorBrush);
        }
示例#2
0
        public override void Draw(DemoTime time)
        {
            if (!_visible)
            {
                return;
            }

            base.Draw(time);

            // Максимальная ширина блока для текста с учетом отступов
            float width = _size.Width - _margin.Y - _margin.W;

            int step = 0;

            if (_isEnterMessage)
            {
                var message = "Сообщение: " + _enterMessage;
                step += lineInMessage(message, width);
                RenderTarget2D.DrawText(message, _textFormat, new RectangleF(
                                            _position.X - _size.Width / 2 + _margin.W,
                                            _position.Y + _size.Height / 2 - _lineHeight * step - _margin.Z,
                                            width,
                                            _lineHeight), _brush);
            }

            // Если включен ввод текста, шаг уже есть
            for (int i = _messages.Count - 1; i >= 0; i--)
            {
                var message   = _messages[i].Item1 + ": " + _messages[i].Item2;
                var lineCount = lineInMessage(message, width);

                // Условие выхода. Если весь текст не влазиет, то и не показываем
                // TODO Сделать чтобы показывалась та часть. которая еще влазиет
                if ((step + lineCount) * _lineHeight + _margin.X + _margin.Z > _size.Height)
                {
                    break;
                }

                var outRectangle = new RectangleF(_position.X - _size.Width / 2 + _margin.W,
                                                  _position.Y - _size.Height / 2 - _margin.Z + _size.Height - _lineHeight * (step + lineCount),
                                                  width,
                                                  _lineHeight * lineCount);

                RenderTarget2D.DrawText(message, _textFormat, outRectangle, _brush);

                step += lineCount;
            }
        }
示例#3
0
        public override void Draw(DemoTime time)
        {
            if (!_visible)
            {
                return;
            }

            base.Draw(time);

            var start = getPosition(Vector2.Zero);
            var size  = getSize();

            RenderTarget2D.DrawText("ID башни: " + _towerId, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
            start = getPosition(new Vector2(0, _lineHeight));
            RenderTarget2D.DrawText("Тип башни: " + _towerType, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
            start = getPosition(new Vector2(0, _lineHeight * 2));
            RenderTarget2D.DrawText("Позиция: " + _towerPosition, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
            start = getPosition(new Vector2(0, _lineHeight * 3));
            RenderTarget2D.DrawText("Радиус: " + _towerRange, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
            start = getPosition(new Vector2(0, _lineHeight * 4));
            RenderTarget2D.DrawText("Скорость: " + _towerFireRate, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
        }
示例#4
0
        public override void Draw(DemoTime time)
        {
            if (!_visible || GameStats == null)
            {
                return;
            }

            base.Draw(time);

            var drawBrush = _brush;

            if (_isRedBrush)
            {
                drawBrush = _brushRed;
            }
            var start = getPosition(Vector2.Zero);
            var size  = getSize();

            RenderTarget2D.DrawText("Деньги: " + GameStats.Money, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), drawBrush);
            start = getPosition(new Vector2(0, _lineHeight));
            RenderTarget2D.DrawText("Дерево: " + GameStats.Woods, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), drawBrush);
        }
示例#5
0
        public override void Draw(DemoTime time)
        {
            if (!_visible)
            {
                return;
            }

            base.Draw(time);

            var start = getPosition(Vector2.Zero);
            var size  = getSize();

            RenderTarget2D.DrawText("ID героя: " + 0, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
            start = getPosition(new Vector2(0, _lineHeight));
            RenderTarget2D.DrawText("Имя героя: " + _playerName, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
            start = getPosition(new Vector2(0, _lineHeight * 2));
            RenderTarget2D.DrawText("Тип героя: " + 0, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
            start = getPosition(new Vector2(0, _lineHeight * 3));
            RenderTarget2D.DrawText("Позиция: " + _playerPosition, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
            start = getPosition(new Vector2(0, _lineHeight * 4));
            RenderTarget2D.DrawText("Скорость перемещения: " + _playerSpeed, _textFormat, new RectangleF(start.X, start.Y, size.Width, size.Height), _brush);
        }