Пример #1
0
        public override void Draw(GameTime gameTime)
        {
            WithZoom(zoom, (b) =>
            {
                base.Draw(gameTime);
                _inputChat.Draw(gameTime);
                // Stop drawing
                if (ChatLines.Count <= 0)
                {
                    SpriteBatch.End();
                    return;
                }
                int count = 0;
                _chatLinesFont.Position = _initialLinePos;

                // Go to every line
                foreach (ChatMessage line in ChatLines)
                {
                    _chatLinesFont.Text  = line.Text;
                    _chatLinesFont.Color = line.Color;

                    if (count > 0) // Passed the first
                    {
                        _chatLinesFont.Alpha    = 1.0F;
                        _chatLinesFont.Position = Positioner.GetSideBy(_chatLinesFont.BoundingBox, _chatLinesFont.BoundingBox, Positioner.SideFrom.Top);
                    }
                    else if (count == 0) // The last, the most recent message
                    {
                        // Checks do animation again
                        if (doAnimation)
                        {
                            _lastMessage = _lastMessage.Transformer(0.0F, 1.0F, 250, gameTime, (t) => _chatLinesFont.Alpha = t.CurrentValue);

                            // If last message animation is done, reset and restart
                            if (_lastMessage.Done)
                            {
                                _lastMessage = null;
                                doAnimation  = false;
                            }
                        }
                    }
                    _chatLinesFont.Draw(gameTime);
                    count++;
                }
                SpriteBatch.End();
            });
        }