What's the proper approach for writing multi-path "story" flows?

Posted by Basiclife on Stack Overflow See other posts from Stack Overflow or by Basiclife
Published on 2010-06-13T22:34:43Z Indexed on 2010/06/13 22:42 UTC
Read the original article Hit count: 179

Hi,

I wonder if you can help me.

I'm writing a game (2d) which allows players to take multiple routes, some of which branch/merge - perhaps even loop. Each section of the game will decide which section is loaded next.

I'm calling each section an IStoryElement - And I'm wondering how best to link these elements up in a way that is easily changed/configured and at the same time, graphable

I'm going to have an engine/factory assembly which will load the appropriate StoryElement(s) based on various config options.

I initially planned to give each StoryElement a NextElement() As IStoryElement property and a Completed() event. When the vent fires, the engine reads the NextElement property to find the next StoryElement.

The downside to this is that if I ever wanted to graph all the routes through the game, I would be unable to - I couldn't determine all possible targets for each StoryElement.

I considered a couple of other solutions but they all feel a little clunky - eg Do I need an additional layer of abstraction? ie StoryElementPlayers or similar - Each one would be responsible for stringing together multiple StoryElement perhaps a Series and a ChoicePlayer with each responsible for graphing its own StoryElement - But this will just move the problem up a layer.

In short, I need some way of emulating a simple but dynamic workflow (but I'd rather not actually use WWF). Is there a pattern for something this simple? All the ones I've managed to find relate to more advanced control flow (parallel processing, etc.)

© Stack Overflow or respective owner

Related posts about .NET

Related posts about design-patterns