2
\$\begingroup\$

For school we have to make a small adventure game in C# (Visual Studio 2015) with a custom game engine made by our teacher. Now I want to implement a small dialog system between Liz (The main characer) and her teddybear.

The way I would like it to work is by using buttons. The bear starts out with "I can't let you pass Liz". Then the player can choose between three options (which are buttons) 1. [Question] 2. [Demand] 3. [Observe].

I am just not sure how to implement this and what would be the most efficient way of doing this codewise. To make it a bit more clear I've added an image of the entire dialog that needs to be implemented. enter image description here

Any help/tips would be welcome!

Thanks in advance

\$\endgroup\$
5
  • \$\begingroup\$ "what would be the most efficient way of doing this codewise." Did you figure out how it could be done in an inefficient way? Did you try anything that did not work? \$\endgroup\$ Commented Jan 17, 2017 at 12:48
  • \$\begingroup\$ I suppose it could be done with alot of booleans turning on and off \$\endgroup\$ Commented Jan 17, 2017 at 12:49
  • 2
    \$\begingroup\$ Possible duplicate of How do dialog trees work? \$\endgroup\$ Commented Jan 17, 2017 at 12:53
  • \$\begingroup\$ There is a lot of resources from questions with the dialog-tree tag. \$\endgroup\$ Commented Jan 17, 2017 at 12:55
  • \$\begingroup\$ Could you mark one of the answers correct? \$\endgroup\$ Commented Mar 21, 2017 at 6:53

2 Answers 2

3
\$\begingroup\$

Imagine the system as rooms with doors/teleports. Every decision is a door, each group of decisions is a room. When you pick a decision, you go from one "room" to a different one.

So, in code terms:

You should have 2 objects, Decision and Group

A decision should know it's type (question, demand, observer) and the next group of decisions it points to, and the groups should store decisions.

In the main class you should have a current group and present the options to the player. When he chooses one, get that decision object and set the current group to the one inside it.

This method is basically a linked list with multiple links.

\$\endgroup\$
5
  • \$\begingroup\$ Uhm, could someone explain the downvote? \$\endgroup\$ Commented Jan 17, 2017 at 14:31
  • \$\begingroup\$ Good answer, but the data structure would be a tree not a linked list. \$\endgroup\$ Commented Jan 17, 2017 at 16:53
  • \$\begingroup\$ @benh A tree has a root and an end, this one doesn't, some dialogs could go straight back to the beginning \$\endgroup\$ Commented Jan 17, 2017 at 17:59
  • \$\begingroup\$ 'tis a graph, guys \$\endgroup\$ Commented Apr 4, 2017 at 22:25
  • \$\begingroup\$ @Mick probably yeah \$\endgroup\$ Commented Apr 5, 2017 at 5:51
-6
\$\begingroup\$

Just code. Lots of IF statements. If your teacher wanted you to do this, the engine or classes would help you.

\$\endgroup\$
3
  • \$\begingroup\$ well the dialog is something I wanted to add as an extra, it's not a requirement \$\endgroup\$ Commented Jan 17, 2017 at 12:51
  • 4
    \$\begingroup\$ -1 "Just code. Lots of IF statements." You could answer this on most of the questions here... \$\endgroup\$ Commented Jan 17, 2017 at 12:54
  • 1
    \$\begingroup\$ You can make any game with lots of if statements. \$\endgroup\$ Commented Jan 17, 2017 at 14:30

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.