A class that will handle the drawing of all dialogue during gameplay. It will be in the LevelManager and it will be updated and drawn by it. The player will will still be able move while dialogue is being shown. A string that represents the whole portion of dialogue will be passed in and this will take care of splitting it into the separate messages by calculating how much can fit inside the message box area. There will be a timer that will set it to the next portion of the dialogue, or the player can press a button to do this before the timer is up.



  • List<string> dialogues - all of the dialogues that will be in a level
  • int currentDialogue - which dialogue in the dialogues array needs to updated/drawn
  • Vector2 startPosition - where the first dialogue line needs to be drawn
  • Vector2 positionOffset - how much the position of each line will be offset from eachother
  • float timer - the timer to check if the next message box should be drawn
  • float duration - how long in seconds each message box will be used
  • SpriteFont font - the font used to draw the dialogue
  • Texture2D messageBox - the message box texture to draw
  • Vector2 messageBoxPosition - where to draw the message box
  • bool dialogueDone - if the dialogue is done


  • LoadDialogue
    • This will be the method that the dialogue data from the Loader will get passed into
    • This method will take in a string for the name of the dialogue and a string which represents the whole dialogue and it will split that up into separate MessageBox's
    • It will do this by using SpriteFont's MeasureString method. It will measure how much of the string can be on each line in the box and how many lines can go in each box.
    • After it has done this it will add the Dialogue to the dialogues array
  • ShowDialogue
    • This will play the dialogue that has the name that is passed in. The LevelManager must call this methods Update and Draw methods after calling this.
    • This will set currentDialogue to the correct index, reset the timer, and set dialogueDone to false
  • Update
    • This will first update the timer, and see if it is greater than the duration
    • If it is it will reset the timer and pop a MessageBox off the Queue in the Dialogue to show the next box
    • If it was the last box then the dialogueDone bool will be set to true
  • NextBox
    • This will force the next message box to show from user input.
    • will set the timer back to 0
    • if that was the last box then dialogueDone will be set to true
  • Draw
    • This will draw the correct message box based on the currentDialogue and the next MessageBox in the Queue
    • It will use the message box dialogue lines and the startPosition and positionOffset Vector2's to draw them in the correct spot.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License