Пример #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);
                }
            }
        }
Пример #2
0
        internal override void Draw(GameTime gameTime)
        {
            // clear backbuffer
            Controller.GraphicsDevice.Clear(BACKGROUND_COLOR);

            var previousTargets = Controller.GraphicsDevice.GetRenderTargets();

            RenderTargetManager.BeginRenderToTarget(_sceneTarget);
            Controller.GraphicsDevice.Clear(BACKGROUND_COLOR);

            _batch.Begin(samplerState: SamplerState.PointClamp);

            var(unit, startX, width, height) = Border.GetDefaultScreenValues();

            // draw empty box at bottom of the screen
            Border.Draw(_batch, startX, StartY + unit * 12, Border.SCREEN_WIDTH, 6, Border.SCALE);

            DrawScreen(gameTime);

            // status
            _enemyPokemonStatus.Draw(_batch);
            _playerPokemonStatus.Draw(_batch);
            _playerStatus.Draw(_batch);
            _pokemonStats.Draw(_batch);

            // battle messages
            _battleTextbox.Draw(_batch, Border.DefaultWhite);

            // main menu
            if (_menuState == BattleMenuState.Main)
            {
                Border.Draw(_batch, startX + unit * 8, StartY + unit * 12, 12, 6, Border.SCALE);

                var menuStr = "";
                for (var i = 0; i < MENU_OPTIONS.Length; i++)
                {
                    if (i == _mainMenuIndex)
                    {
                        menuStr += ">";
                    }
                    else
                    {
                        menuStr += " ";
                    }

                    menuStr += MENU_OPTIONS[i].PadRight(5);

                    if (i == 1)
                    {
                        menuStr += "\n";
                    }
                }
                _fontRenderer.LineGap = 1;
                _fontRenderer.DrawText(_batch, menuStr,
                                       new Vector2(startX + unit * 9, StartY + unit * 14), Color.Black, Border.SCALE);
            }
            else if (_menuState == BattleMenuState.Fight)
            {
                Border.Draw(_batch, startX + unit * 4, StartY + unit * 12, 16, 6, Border.SCALE);

                // move list
                var pokemon     = Battle.ActiveBattle.PlayerPokemon.Pokemon;
                var moveListStr = "";
                for (var i = 0; i < Pokemon.MAX_MOVES; i++)
                {
                    if (i == _moveMenuIndex)
                    {
                        moveListStr += ">";
                    }
                    else
                    {
                        moveListStr += " ";
                    }
                    if (pokemon.Moves.Length > i)
                    {
                        moveListStr += pokemon.Moves[i].name;
                    }
                    else
                    {
                        moveListStr += "-";
                    }
                    moveListStr += "\n";
                }
                _fontRenderer.LineGap = 0;
                _fontRenderer.DrawText(_batch, moveListStr,
                                       new Vector2(startX + unit * 5, StartY + unit * 13), Color.Black, Border.SCALE);

                // move info
                Border.Draw(_batch, startX, StartY + unit * 8, 11, 5, Border.SCALE);

                var selectedMove = pokemon.Moves[_moveMenuIndex];
                // disabled?
                if (Battle.ActiveBattle.PlayerPokemon.DisabledMove == selectedMove &&
                    Battle.ActiveBattle.PlayerPokemon.DisabledTurns > 0)
                {
                    _fontRenderer.DrawText(_batch, "Disabled!",
                                           new Vector2(startX + unit, StartY + unit * 10), Color.Black, Border.SCALE);
                }
                else
                {
                    _fontRenderer.DrawText(_batch,
                                           "TYPE/\n" +
                                           " " + selectedMove.GetMove().Type.ToString().ToUpper() + "\n" +
                                           new string(' ', 4) + selectedMove.pp.ToString().PadLeft(2) + "/" +
                                           selectedMove.maxPP.ToString().PadLeft(2),
                                           new Vector2(startX + unit, StartY + unit * 9), Color.Black, Border.SCALE);
                }
            }

            // animations
            lock (_animations)
            {
                foreach (var animation in _animations)
                {
                    if (!animation.IsFinished)
                    {
                        animation.Draw(_batch);
                    }
                }
            }

            _batch.End();

            Controller.GraphicsDevice.SetRenderTargets(previousTargets);

            if (_invertColors)
            {
                _batch.Begin(samplerState: SamplerState.PointClamp, blendState: INVERT_COLORS_BLENDSTATE, effect: _screenEffect);
            }
            else
            {
                _batch.Begin(samplerState: SamplerState.PointClamp, effect: _screenEffect);
            }

            var color = Color.White;

            if (_fadeOut)
            {
                color = new Color(255, 255, 255, (int)(255 * (1f - _fadeOutProgress)));
            }
            _batch.Draw(_sceneTarget, _screenOffset, color);

            _batch.End();
        }