public MessageInputHandler(WorldInstance worldInstance, MessageRendererState messageRendererState, TimeSpan totalTime, Action<IXnaGameTime> messageClosingDelegate)
        {
            worldInstance.ThrowIfNull("worldInstance");
            messageRendererState.ThrowIfNull("messageRendererState");
            messageClosingDelegate.ThrowIfNull("messageClosingDelegate");

            _worldInstance = worldInstance;
            _messageRendererState = messageRendererState;
            _messageClosingDelegate = messageClosingDelegate;
            _answerKeyboardStateHelper = new KeyboardStateHelper(
                KeyDown,
                null,
                null,
                TextAdventure.Xna.Constants.MessageRenderer.Input.AcceptKey,
                TextAdventure.Xna.Constants.MessageRenderer.Input.NextAnswerKey,
                TextAdventure.Xna.Constants.MessageRenderer.Input.PreviousAnswerKey);
            _scrollKeyboardStateHelper = new KeyboardStateHelper(
                _scrollKeyboardRepeatHelper,
                TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollUpKey,
                TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollDownKey,
                TextAdventure.Xna.Constants.MessageRenderer.Input.HomeKey,
                TextAdventure.Xna.Constants.MessageRenderer.Input.EndKey,
                TextAdventure.Xna.Constants.MessageRenderer.Input.PageUpKey,
                TextAdventure.Xna.Constants.MessageRenderer.Input.PageDownKey);
            _scrollKeyboardRepeatHelper.InitialInterval = TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollKeyboardInterval;
            _scrollKeyboardRepeatHelper.RepeatingInterval = TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollKeyboardInterval;
        }
        public MessageFadeOutAndScaleUpdater(MessageRendererState messageRendererState, TimeSpan totalTime, Action completeDelegate)
        {
            messageRendererState.ThrowIfNull("messageRendererState");
            completeDelegate.ThrowIfNull("completeDelegate");
            if (totalTime < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("totalTime");
            }

            _messageRendererState = messageRendererState;
            _completeDelegate = completeDelegate;
            _timedLerpHelper = new TimedLerpHelper(totalTime, TextAdventure.Xna.Constants.MessageRenderer.FadeOutDuration, 1f, 0f);
        }
        private void ProcessMessage(TimeSpan totalGameTime)
        {
            bool processingMessage = _messageRenderer != null;
            bool messageAvailable = !_worldInstance.WorldTime.Paused && _worldInstance.MessageMananger.Count > 0;

            if (processingMessage || !messageAvailable)
            {
                return;
            }

            _messageRendererState = new MessageRendererState
                {
                    Message = _worldInstance.MessageMananger.DequeueMessage()
                };
            _messageRenderer = new MessageRenderer(_messageRendererState);
            _messageFadeInAndScaleUpdater = new MessageFadeInAndScaleUpdater(_messageRendererState, totalGameTime, MessageOpened);

            _rendererCollection.Add(_messageRenderer);
            _updaterCollection.Add(_messageFadeInAndScaleUpdater);

            _inputManager.ClaimFocus(Focus.Message);
        }
        private void MessageClosed()
        {
            IMessage message = _messageRendererState.Message;

            _updaterCollection.Remove(_messageFadeOutAndScaleUpdater);
            _rendererCollection.Remove(_messageRenderer);
            _messageFadeOutAndScaleUpdater = null;
            _messageRenderer = null;
            _messageRendererState = null;

            _inputManager.RelinquishFocus();

            _worldInstance.MessageMananger.MessageClosed(message);
        }