public void updateResources(StoryResourceStore resources) { _waterText.text = resources.getResource("water").ToString(); _oxygenText.text = resources.getResource("oxygen").ToString(); _energyText.text = resources.getResource("energy").ToString(); _steelText.text = resources.getResource("metal").ToString(); _crewText.text = resources.getResource("crew").ToString(); _foodText.text = resources.getResource("food").ToString(); }
public void processResult(StoryResourceStore store) { Debug.Log("processing " + results.Count + " results"); for (int i = 0; i < results.Count; i++) { Debug.Log("removing " + results[i].amount + " " + results[i].name); store.addResource(results[i].name, results[i].amount); } }
public List <string> getChoises(StoryResourceStore store) { for (int i = 0; i < results.Count; i++) { //Debug.Log("checking...."); if (results[i].checkResult(store)) { return(results[i].choises); } } return(new List <string>()); }
public List <string> choises = new List <string>(); // options for next action by event name public bool checkResult(StoryResourceStore store) { //Debug.Log("Running event check"); for (int i = 0; i < requirements.Count; i++) { //Debug.Log("Checking: " + requirements[i].name + " "); if (store.getResource(requirements[i].name) < requirements[i].amount) { //Debug.Log("Not enought"); return(false); } } return(true); }
public string getResults(StoryResourceStore store) { //Debug.Log("Event " + name); //Debug.Log("getting results for new event, " + results.Count); for (int i = 0; i < results.Count; i++) { //Debug.Log("checking...."); if (results[i].checkResult(store)) { results[i].processResult(store); return(results[i].eventText); } } return("You were unable to do anything (this is error in event results)"); }
public List <StoryResource> readResourceData(string filename, StoryResourceStore store) { List <StoryResource> resourceList = new List <StoryResource>(); StreamReader reader = new StreamReader(filename); string line; while ((line = reader.ReadLine()) != null) { line = line.Trim(); string[] lines = line.Split(' '); if (lines.Length == 2) { string name = lines [0]; int amount = Int32.Parse(lines [1]); store.addResource(name, amount); } } return(resourceList); }