Exemplo n.º 1
0
        public void Draw(SpriteBatch batch, Color color)
        {
            if (Visible)
            {
                var height = (int)(HEIGHT * Border.UNIT * Border.SCALE);
                var width  = (int)(Border.SCREEN_WIDTH * Border.UNIT * Border.SCALE);
                var unit   = (int)(Border.UNIT * Border.SCALE);
                var startX = Controller.ClientRectangle.Width / 2 - width / 2;
                var startY = OffsetY;

                Border.Draw(batch, startX, startY, Border.SCREEN_WIDTH, HEIGHT, Border.SCALE, color);

                var previousTargets = Controller.GraphicsDevice.GetRenderTargets();
                RenderTargetManager.BeginRenderToTarget(_textTarget);
                Controller.GraphicsDevice.Clear(Color.Transparent);

                _textBatch.Begin(samplerState: SamplerState.PointClamp);

                var lines = _text[_textIndex];

                var line1       = lines[_lineIndex];
                var line1Length = line1.Length;

                line1 = line1.Substring(0, Math.Min(_charIndex, line1Length));

                _fontRenderer.DrawText(_textBatch, line1,
                                       new Vector2(unit, unit * 2 - 32 - _scrollValue),
                                       Color.Black, Border.SCALE);

                if (line1Length == line1.Length && lines.Length > _lineIndex + 1)
                {
                    var line2 = lines[_lineIndex + 1];
                    line2 = line2.Substring(0, _charIndex - line1Length);

                    _fontRenderer.DrawText(_textBatch, line2,
                                           new Vector2(unit, unit * 4 - 32 - _scrollValue),
                                           Color.Black, Border.SCALE);
                }

                _textBatch.End();

                Controller.GraphicsDevice.SetRenderTargets(previousTargets);

                batch.Draw(_textTarget, new Vector2(0, 32) + new Vector2(startX, startY), Color.White);

                // draw advance arrow
                // do this when there is another text block/line
                if (_arrowVisible && !_scrolling && CanAdvance() &&
                    (AlwaysDisplayContinueArrow || (lines.Length > _lineIndex + 2 || _text.Length > _textIndex + 1)))
                {
                    batch.Draw(_continueArrow,
                               new Rectangle(startX + width - unit * 2, startY + height - unit, unit, unit),
                               color);
                }
            }
        }
Exemplo n.º 2
0
 public void Draw(SpriteBatch batch, Color color)
 {
     if (Visible)
     {
         var unit   = (int)(Border.SCALE * Border.UNIT);
         var startY = OffsetY;
         if (_displayCost)
         {
             var startX = (int)(Controller.ClientRectangle.Width / 2f + Border.SCREEN_WIDTH * unit / 2f - WIDTH_COST * unit);
             Border.Draw(batch, startX, OffsetY, WIDTH_COST, HEIGHT, Border.SCALE, color);
             var cost = ("$" + (_cost * _current).ToString()).PadLeft(7);
             _fontRenderer.DrawText(batch, "*" + _current.ToString("D2") + cost,
                                    new Vector2(startX + unit, startY + unit), Color.Black, Border.SCALE);
         }
         else
         {
             var startX = (int)(Controller.ClientRectangle.Width / 2f + Border.SCREEN_WIDTH * unit / 2f - WIDTH * unit);
             Border.Draw(batch, startX, OffsetY, WIDTH, HEIGHT, Border.SCALE, color);
             _fontRenderer.DrawText(batch, "*" + _current.ToString("D2"),
                                    new Vector2(startX + unit, startY + unit), Color.Black, Border.SCALE);
         }
     }
 }
Exemplo n.º 3
0
        public void Draw(SpriteBatch batch, Color color)
        {
            if (Visible)
            {
                var width  = (int)(_width * Border.UNIT * Border.SCALE);
                var height = (int)(Height * Border.UNIT * Border.SCALE);
                var unit   = (int)(Border.UNIT * Border.SCALE);
                var startX = OffsetX;
                var startY = OffsetY - height;

                Border.Draw(batch, startX, startY, _width, Height, Border.SCALE, color);

                var text = string.Join(Environment.NewLine, _options.Select((t, i) => (i == Index ? ">" : " ") + t));

                _fontRenderer.DrawText(batch, text,
                                       new Vector2(startX + unit, startY + unit + BufferUp * unit),
                                       Color.Black, Border.SCALE);
            }
        }