Jump to content
  • Advertisement
JustHusk

C# Making Decisions In Text Adventures!

Recommended Posts

Hi there,

So i'm an inexperienced student learning games dev at college and im studying c#, in my spare time im trying to work on a text adventure game with a narrative. My issue is that i dont know how to make the decisions, well not simply anyhow.

I could write out 50 variables for each decision to read from the player but that would become very tedious and too messy to even comprehend when im adding content. I was thinking of adding functions to hold each decision or area but im at a lack of knowledge on how to jump to a function or if it's even a good solution. I know i could use an array and each decision be a number but that just doesn't seem like a good solution to me either.

Any advice would be appreciated and this whole topic might sound dumb to a professional so be understanding please haha.

Thanks,

Luke

Share this post


Link to post
Share on other sites
Advertisement
5 minutes ago, Septopus said:

You could also use something like a State Machine to do these kinds of things...

https://sachabarbs.wordpress.com/2013/05/16/simple-but-nice-state-machine/

Thank you for the suggestions!

As i'm still quite inexperienced it's hard to wrap my head around some of the concepts so it'll take some time to tell what'll work for me but both seem like great solutions.

I'll update this after some messing about, thanks again!

Share this post


Link to post
Share on other sites

There may even be a simpler method out there, that I'm overlooking, but hopefully those search terms will get you closer to your goal.  There are also some game engines out there specifically for building your own text adventure game, I think some are open source.  Have a peek under the hood of one. ;) 

Have a google at "c# text adventure engine" .. at least 2 or 3 there at the top.  Dissection is the best way to learn sometimes. :D

Just don't always assume the code you are taking apart was put together well.

 

Share this post


Link to post
Share on other sites
44 minutes ago, Septopus said:

There may even be a simpler method out there, that I'm overlooking, but hopefully those search terms will get you closer to your goal.  There are also some game engines out there specifically for building your own text adventure game, I think some are open source.  Have a peek under the hood of one. ;) 

Have a google at "c# text adventure engine" .. at least 2 or 3 there at the top.  Dissection is the best way to learn sometimes. :D

Just don't always assume the code you are taking apart was put together well.

 

Yeah don't think i want to use an engine, even by itself i'm struggling with the links you sent me.

I have no reference to understand it,

public bool Result { get; set; }

the parameters of the line above i'm not familiar with and i'm pretty sure that's the simplest thing on the page, anything you could recommend for beginners?

Share this post


Link to post
Share on other sites

Then I would say start with some introductory tutorials on c# & c# Object Oriented Programming.  You need some exposure to some of the fundamental basics, and well I'm not the guy for that.  Lol.  Start with YouTube if you prefer visual learning.  Wish I had a list of good ones,but it's been a while since I checked any out. You could probably get some better suggestions for tutorials in the Beginners forum though.  Good luck with your project! :D

Share this post


Link to post
Share on other sites

Here is an old 3DBuzz text adventure game in C#. It later uses XNA but this first section is only C#. I watched a couple years ago and it seemed to be interesting so I pass it on. The later parts are not free but this first part is many hours long and is complete.

Keep in mind that it is old and you may have to do some workarounds. I have always found that a learning experience in itself. Also some best practices may have evolved since this course was made.

RIP to Jason Busby

Here is the 3rd part for your consideration. The first 2 are very basic intro and install.

 

Playlist is

https://www.youtube.com/watch?v=OOiSIajp4gw&list=PL74F05D68F408B2DD&index=1

 

Share this post


Link to post
Share on other sites

There are professional tools out to maintain those decision trees and export into any format you need to work with your game.

The simplest solution as already mentioned is the decision tree, a structure that is a collection of connected logic nodes that each may also have child nodes attached to. When verifyng your tree you'll start with a reference to the root node and test it's children. You then take a reference to the children whitch first returned true on validation as your next root node and repeat until you reach the end of the tree and so the end of your game. Meanwhile there could also be action nodes between so run those node's functions to interact with your game

Share this post


Link to post
Share on other sites
7 minutes ago, Shaarigan said:

There are professional tools out to maintain those decision trees and export into any format you need to work with your game.

The simplest solution as already mentioned is the decision tree, a structure that is a collection of connected logic nodes that each may also have child nodes attached to. When verifyng your tree you'll start with a reference to the root node and test it's children. You then take a reference to the children whitch first returned true on validation as your next root node and repeat until you reach the end of the tree and so the end of your game. Meanwhile there could also be action nodes between so run those node's functions to interact with your game

Thanks for the suggestions, again i am just learning at college level and although i'm doing this project because im ahead of my class and need something harder i dont really have a grasp on a lot of the keywords etc. I feel like it must be bad practice but would it be okay to just call methods depending on the players decisions?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!