O'Reilly logo

Microsoft XNA 4.0 Game Development Cookbook by Luke Drumm

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Constructing dialogue

Whether divulging small nuggets of information, engaging in trade, or just adding that little bit of texture, for gaming genres such as the role-playing game, the ability to converse with characters in the surrounding world is often at the heart of the storytelling process.

In this recipe, we're going to examine a technique for constructing dialogue trees loosely based on the Gang of Four command pattern.

Getting ready

An XNA-compatible font of your choice is all that's required for this recipe.

How to do it...

To create a dialogue engine:

  1. Add a new SpriteFont to the solution named Dialogue.
  2. Create an interface to define how to interact with an NPC during conversation:
    interface ChatSupplier { IEnumerable<ChatOptionDisplayable> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required