Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a tree of required items
    text
    copied!<p>As I am developing my small game, I have made a lot of progress yet frustrated about a lot of things. The latest thing was <code>creating a list of required items</code> and for you to understand that I will provide you with both <code>Explanation</code> as well as <code>Code</code> which I created but obviously doesn't work...</p> <p>I - Explanation</p> <p>In order for the player to build a building he must have done some required researches with each research requires more researches for it to be researched... It is like a tree of researches that the player will go through them by exploring the game and doing some tasks...</p> <p>So to imagine it more accurately you can look at my small <em>code</em> here</p> <p>II - Code</p> <pre><code> //Available Main Elements var carbon = new Element {Name = "Carbon"}; var hydrogen = new Element {Name = "Hydrogen"}; var oxygen = new Element {Name = "Oxygen"}; var nitrogen = new Element {Name = "Nitrogen"}; //Example Research var steam = new Research(name : "Steam", requiredElements: null, requiredResearches: /*Fire*/ &amp; /*Water*/ &amp; /*Iron*/); </code></pre> <p>So from the last snippet of code [which is just to explain] the player want to research the <code>Steam</code> that for instance needs 3 more researches in order to be researched... one of which <code>the Iron</code> also needs 1 more research to be researched and so on [maybe less maybe more or maybe no requirements at all]...</p> <p>Concluding that the Question is : <em>How could I create such nesting so that when a player tries to do a research the system quickly looks at the researches he have done and the research he wants to do [including it's nested ones] and If the player did not meet the requirements it just returns a tree with what things he want's to achieve</em> ?</p> <p>After all, I just want to thank you in advance and I am waiting for your very valuable support...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload