Method for Creating a "Choose Your Own Adventure Game" C#
First off, I'm not looking for a super in depth solution to the question.
Basically I was just trying to make a Choose your own adventure game and aside from making a continuous set of If Then statements to create the branching story (which is extremely unfeasible), I 'm not sure how else to store information to allow the story to go forward.
I was just kind of curious if anyone has had luck or if there is a method that someone could point me towards where I could set up some sort of script that would be easily editable and allow for a story to take place with branching stories to happen.
(I'm thinking it may have something to do with different states being present in the script representing where the player is in the story, and somehow the player should be able to choose an option that throws them into a different state)
Any general ideas or any place where I could go to figure this out?
@ReedSchneider Honestly, this is a really good question, because I'm struggling with figuring out how to deal with this too.
I think your initial assessment is on the right track, but I'm not too certain there is an easy solution for what you are asking for.
Right, so... the whole thing that we want is to have branching story paths. By it's very nature, there will need to be some branching if/conditional logic... but how to structure that in an easily maintainable and modular way?
After a quick search online, I found this: http://program$$anonymous$$gisfun.com/learn/c-sharp-adventure-game/c_sharp_08_branching_narrative/ Which seems to have some good ideas on how to go about it.
Right... I think that, maybe one way to do it, is to think of a plot point/story event like "quests". A quest may have prerequisites before the player can acquire it/ the quest marker will show up... or in this case, before a story event will trigger (For example, prerequisite quests, level of the player, etc).
So... we need a way to store/track the player's progress/state so a 'quest' can deter$$anonymous$$e if it can be obtained/triggered... which is pretty normal. To keep track of previous quests, we can just attach a quest log to the player... or, in the case of branching stories, a story log! The story log might just be a list/dictionary/collection like ([Quest, Status], [Quest, Status])... where status is a Boolean to see if it's complete or not complete. Although that raises an issue where a quest might have multiple outcomes, so maybe you might need to store more complex logic, or you need to break the different outcomes into different sub-quests.
I dunno, it's tricky ¯_(ツ)_/¯
Huh, the next... chapter thingo by the same dude as the last link goes on about the sort of 'questing' system I was trying to elaborate... in a more elegant and diagrammed way.
http://program$$anonymous$$gisfun.com/learn/c-sharp-adventure-game/c_sharp_10_content_arrays/
Well... partly, as the guy warns:
However, what if we later want to add more scenarios and make the game play longer? We would need to find this loop in our code and manually update it. Since our project is so small, this isn't too much trouble. But if we keep expanding our project, or work on another project that is much larger that has several references to a number that might change later, we would want to have a better solution than having "hard coded" data.
So it needs to abstracted/generalized to the point you can load in an arbitrary number of story points, with arbitrary 'trigger' conditions.
Haven't used this before, I just remembered seeing this. I am currently trying to use csv, but have nothing to share XD Because I'm also thinking about how I should implement the system. About the "where the player is in the story" thing, because I can get current csv file name and line number, so it's doable for me. I guess for my system, every story branch will be a text file... and I load them dynamically. (ps. if you search "Unity Visual Novel" you might find something helpful)
Your answer
Follow this Question
Related Questions
Disable and enable emission property of a material via C# script? 0 Answers
Quiz Game Management 0 Answers
Acessing function in another script C# - just dont get it - code shown 1 Answer
Need help with project architecture (specifically store/access static values) 0 Answers
script an delay 0 Answers