public void Update(GameTime gameTime)
        {
            controls.Update(gameTime);
            debugControls.Update(gameTime);
            switch (currentState)
            {
                case DialogManagerState.BeginShowDialog:

                    if (screenCoverAlpha < 0.5f)
                    {
                        screenCoverAlpha += dialogFadeSpeed;
                    }
                    else
                    {
                        screenCoverAlpha = 0.5f;
                    }

                    if (screenCoverAlpha == 0.5f)
                    {

                        if (topDialogBox.DialogCharacter == currentConversation.sentences[0].characterTalking)
                        {
                            activeDialogBox = topDialogBox;
                        }

                        else if (bottomDialogBox.DialogCharacter == currentConversation.sentences[0].characterTalking)
                        {
                            activeDialogBox = bottomDialogBox;
                        }

                        activeDialogBox.CurrentState = DialogBoxState.FadingIn;
                        activeDialogBox.Text = currentConversation.sentences[0].sentenceText;
                        sentenceProgress = 0;
                        WrapText();
                        currentState = DialogManagerState.ShowingText;
                    }
                    break;

                case DialogManagerState.EndShowDialog:
                     if (screenCoverAlpha > 0.0f)
                    {
                        screenCoverAlpha -= dialogFadeSpeed;
                    }
                    else
                    {
                        screenCoverAlpha = 0.0f;
                    }

                     if (screenCoverAlpha == 0.0f)
                     {
                         activeDialogBox = null;
                         topDialogBox = null;
                         bottomDialogBox = null;
                         player.ControlsActive = true;
                         player.DebugControlsActive = true;
                         currentState = DialogManagerState.IdleHidden;
                     }
                    break;

                case DialogManagerState.ShowingText:
                    currentTextTime += GameClass.Elapsed;

                    if (currentTextTime > currentTextSpeed)
                    {
                        currentTextTime = 0.0f;
                        if (sentenceProgress < activeDialogBox.Text.Length)
                        {
                            sentenceProgress += 1;
                            GameClass.SoundManager.PlaySoundEffect("Audio/dialogSound");
                        }
                        else
                        {
                            currentState = DialogManagerState.AwaitingInput;
                            inputIconAlpha = 1.0f;

                            inputIconState = InputIconState.Flashing;
                        }
                    }

                        if (controls.ButtonPressed(Buttons.B, true, false) || debugControls.KeyPressed(Keys.RightShift, true, false))
                        {
                            currentTextSpeed = fastTextSpeed;
                        }

                        if (controls.ButtonReleased(Buttons.B) && debugControls.KeyReleased(Keys.RightShift))
                        {
                            currentTextSpeed = slowTextSpeed;
                        }

                    break;

                case DialogManagerState.AwaitingInput:

                        if (controls.ButtonPressed(Buttons.B, false, false) || debugControls.KeyPressed(Keys.RightShift, false, false))
                        {
                            NextSentence();
                            GameClass.SoundManager.PlaySoundEffect("Audio/menuConfirm");
                        }
                    break;
            }

            if (activeDialogBox != null)
            {
                switch (activeDialogBox.CurrentState)
                {
                    case DialogBoxState.FadingIn:
                        if (activeDialogBox.Alpha < 1.0f)
                        {
                            activeDialogBox.Alpha += dialogFadeSpeed;
                        }
                        else
                        {
                            activeDialogBox.CurrentState = DialogBoxState.ShowingActive;
                            currentState = DialogManagerState.ShowingText;
                        }
                        break;
                    case DialogBoxState.FadingOut:
                        if (activeDialogBox.Alpha > 0.0f)
                        {
                            activeDialogBox.Alpha -= dialogFadeSpeed;
                        }
                        else
                        {
                            activeDialogBox.CurrentState = DialogBoxState.Hidden;
                        }
                        break;
                }
            }

            if (inactiveDialogBox != null)
            {
                switch (inactiveDialogBox.CurrentState)
                {
                    case DialogBoxState.FadingToInactive:
                        if (inactiveDialogBox.Alpha > 0.75f)
                        {
                            inactiveDialogBox.Alpha -= dialogFadeSpeed;
                        }
                        else
                        {
                            inactiveDialogBox.CurrentState = DialogBoxState.ShowingInactive;
                        }
                        break;
                    case DialogBoxState.FadingOut:
                        if (inactiveDialogBox.Alpha > 0.0f)
                        {
                            inactiveDialogBox.Alpha -= dialogFadeSpeed;
                        }
                        else
                        {
                            inactiveDialogBox.CurrentState = DialogBoxState.Hidden;
                        }
                        break;
                }
            }

            switch (inputIconState)
            {
                case InputIconState.Hidden:
                    inputIconAlpha = 0.0f;
                    break;

                case InputIconState.FadingIn:
                    if (inputIconAlpha < 1.0f)
                    {
                        inputIconAlpha += inputIconFlashSpeed;
                    }
                    else
                    {
                        inputIconState = InputIconState.Flashing;
                    }
                    break;

                case InputIconState.Flashing:
                    if (inputFlashDirection == 0)
                    {
                        if (inputIconAlpha < 1.0f)
                        {
                            inputIconAlpha += inputIconFlashSpeed;
                        }
                        else
                        {
                            inputIconAlpha = 1.0f;
                            inputFlashDirection = 1;
                        }
                    }
                    else if (inputFlashDirection == 1)
                    {
                        if (inputIconAlpha > 0.5f)
                        {
                            inputIconAlpha -= inputIconFlashSpeed;
                        }
                        else
                        {
                            inputIconAlpha = 0.5f;
                            inputFlashDirection = 0;
                        }
                    }

                    break;
                case InputIconState.FadingOut:
                     if (inputIconAlpha > 0.0f)
                    {
                        inputIconAlpha -= inputIconFlashSpeed;
                    }
                    else
                    {
                        inputIconState = InputIconState.Hidden;
                    }
                    break;
            }
        }
        public void LoadConversation(PlayerMapCharacter player, QuestDialogData questDialogData)
        {
            autoDialog = true;
            this.player = player;

            foreach (QuestDialogSentenceData sentence in questDialogData.sentences)
            {
                if (sentence.characterTalking != player.CharacterID)
                {
                    this.NPCTriggerID = sentence.characterTalking;
                    break;
                }
            }

            topDialogBox = new DialogBox(new Vector2(GameClass.CurrentGameCamera.Position.X + GameClass.ViewPortBounds.Width / 2, GameClass.CurrentGameCamera.Position.Y + 90));
            bottomDialogBox = new DialogBox(new Vector2(GameClass.CurrentGameCamera.Position.X + GameClass.ViewPortBounds.Width / 2, GameClass.CurrentGameCamera.Position.Y + 190));
            currentSentenceIndex = 0;
            currentSentenceOrderID = 0;
            inputIconTexture = GameClass.LoadTextureData("General/BButton");
            inputIconAlpha = 0.0f;
            inputIconState = InputIconState.Hidden;
            inputFlashDirection = 0;

            currentState = DialogManagerState.IdleHidden;

            topDialogBox.DialogCharacter = NPCTriggerID;
            topDialogBox.PortraitTexture = GameClass.LoadTextureData("MapCharacters/" + NPCTriggerID.ToString() + "/" + NPCTriggerID.ToString() + "Portrait");

            bottomDialogBox.DialogCharacter = player.CharacterID;
            bottomDialogBox.PortraitTexture = player.PortraitTexture;

            screenCoverTexture = GameClass.LoadTextureData("Black");
            screenCoverAlpha = 0.0f;

            currentConversation = questDialogData;

            currentSentenceIndex = 0;
            currentSentenceOrderID = 0;
            currentState = DialogManagerState.BeginShowDialog;
        }
        public void NextSentence()
        {
            inputIconState = InputIconState.Hidden;

            int nextSentenceIndex = 0;
            if (remainderText == "")
            {
                int nextSentenceOrderID = 0;

                foreach (QuestDialogOptionData response in currentConversation.sentences[currentSentenceIndex].responseOptions)
                {
                    if (response.optionName == "DEFAULT")
                    {
                        if (response.flagChangesOnResponse != null)
                        {
                            foreach (QuestFlagChangeData flagChange in response.flagChangesOnResponse)
                            {
                                GlobalGameInfo.SetQuestFlag(flagChange.flagNameToChange, flagChange.changeValue, flagChange.flagValueChangeType);
                            }
                        }

                        nextSentenceOrderID = response.nextSentence;
                        if (nextSentenceOrderID == -1)
                        {
                            UnloadConversation();
                            break;
                        }
                        else
                        {
                            bool nextSentenceExists = false;
                            for (int i = 0; i < currentConversation.sentences.Count; i++)
                            {
                                if ((currentConversation.sentences[i].characterTalking == player.CharacterID || currentConversation.sentences[i].characterTalking == NPCTriggerID) && currentConversation.sentences[i].sentenceID == nextSentenceOrderID)
                                {
                                    nextSentenceIndex = i;
                                    nextSentenceExists = true;
                                }
                            }

                            if (!nextSentenceExists)
                            {
                                UnloadConversation();
                            }
                            else
                            {
                                currentSentenceIndex = nextSentenceIndex;
                                currentSentenceOrderID = nextSentenceOrderID;

                                inactiveDialogBox = activeDialogBox;
                                inactiveDialogBox.CurrentState = DialogBoxState.FadingToInactive;
                                if (currentConversation.sentences[currentSentenceIndex].characterTalking == player.CharacterID)
                                {
                                    activeDialogBox = bottomDialogBox;
                                }
                                else if (currentConversation.sentences[currentSentenceIndex].characterTalking == NPCTriggerID)
                                {
                                    activeDialogBox = topDialogBox;
                                }
                                activeDialogBox.Text = currentConversation.sentences[currentSentenceIndex].sentenceText;
                                sentenceProgress = 0;
                                activeDialogBox.CurrentState = DialogBoxState.FadingIn;
                                WrapText();
                            }
                        }
                    }
                }

            }
            else
            {
                sentenceProgress = 0;
                activeDialogBox.Text = remainderText;
                currentState = DialogManagerState.ShowingText;
                remainderText = "";
                WrapText();
            }
        }
        public void LoadConversation(PlayerMapCharacter player, NPCMapCharacter NPCConversationTrigger)
        {
            autoDialog = false;
            this.player = player;
            this.NPCTriggerID = NPCConversationTrigger.CharacterID;

            topDialogBox = new DialogBox(new Vector2(GameClass.CurrentGameCamera.Position.X + GameClass.ViewPortBounds.Width / 2, GameClass.CurrentGameCamera.Position.Y + 90));
            bottomDialogBox = new DialogBox(new Vector2(GameClass.CurrentGameCamera.Position.X + GameClass.ViewPortBounds.Width / 2, GameClass.CurrentGameCamera.Position.Y + 190));
            currentSentenceIndex = 0;
            currentSentenceOrderID = 0;
            inputIconTexture = GameClass.LoadTextureData("General/BButton");
            inputIconAlpha = 0.0f;
            inputIconState = InputIconState.Hidden;
            inputFlashDirection = 0;

            currentState = DialogManagerState.IdleHidden;

            player.CurrentAction = MapCharacterAction.Idle;

            topDialogBox.DialogCharacter = NPCConversationTrigger.CharacterID;
            topDialogBox.PortraitTexture = NPCConversationTrigger.PortraitTexture;

            bottomDialogBox.DialogCharacter = player.CharacterID;
            bottomDialogBox.PortraitTexture = player.PortraitTexture;

            screenCoverTexture = GameClass.LoadTextureData("Black");
            screenCoverAlpha = 0.0f;

            bool convoTriggered = false;
            foreach(QuestDialogData dialogData in NPCConversationTrigger.LinkedNPCData.dialog)
            {
                if (dialogData.flagsToTrigger != null)
                {
                    int triggerCount = dialogData.flagsToTrigger.Count;
                    int flagsTriggered = 0;
                    foreach (QuestFlagData flagTriggerRequirement in dialogData.flagsToTrigger)
                    {
                        if (GlobalGameInfo.CheckFlagTrigger(dialogData.flagsToTrigger) == true)
                        {
                            flagsTriggered += 1;
                        }
                    }

                    if (flagsTriggered == triggerCount)
                    {
                        convoTriggered = true;
                        currentConversation = dialogData;
                        break;
                    }
                }
                else
                {
                    convoTriggered = true;
                    currentConversation = dialogData;
                    break;
                }
            }

            if (convoTriggered == false)
            {
                throw new Exception("no conversation found.");
            }
            else
            {

                currentSentenceIndex = 0;
                currentSentenceOrderID = 0;
                currentState = DialogManagerState.BeginShowDialog;
            }
        }