/// <summary> /// Add resource to be stored on Land spaces. /// </summary> /// <param name="ecoEditor">Wrapper for ecosystem.</param> /// <param name="name">Name of resource. Use this same name when creating creature resources.</param> /// <param name="initialAmt">Initial amount stored on a Land. Note: this parameter may be ignored by MapEditor when distributing the resource.</param> /// <param name="maxAmt">Max amount stored on a Land.</param> /// <param name="consumedPerTime">Amount of the resource consumed per unit of time.</param> /// <param name="proportionExtract">Proportion of the amount consumed that is actually extracted. This proportion is modified by the creature's ability to extract this resource.</param> /// <param name="renewAmt">The amount of the resource renewed every renew interval (see setEcoParams).</param> public static void addResource(EcosystemEditor ecoEditor, string name, float initialAmt, float maxAmt, float consumedPerTime, float proportionExtract, float renewAmt) { LandResourceEditor lre = ecoEditor.addResource(name); lre.setAmountOfResource(initialAmt); lre.setMaxAmt(maxAmt); lre.setAmtConsumedPerTime(consumedPerTime); lre.setProportionExtracted(proportionExtract); // higher proportion extracted for primary resources lre.setRenewalAmt(renewAmt); }
/// <summary> /// saves all information that the user entered into the menu /// </summary> public void saveSettings() { string name = resNameText.GetComponent <Text>().text; ecoEditor.addResource(name); lrEditor = ecoEditor.lre; // TODO : covert HelperSetter to ValidationHelper string amtstoredString = amtStoredText.GetComponent <Text>().text; if (HelperValidator.validateFloatString(amtstoredString)) { lrEditor.setAmountOfResource(float.Parse(amtstoredString)); } string maxAmtString = maxAmtText.GetComponent <Text>().text; if (HelperValidator.validateFloatString(maxAmtString)) { lrEditor.setMaxAmt(float.Parse(maxAmtString)); } string renAmtString = renewAmtText.GetComponent <Text>().text; if (HelperValidator.validateFloatString(renAmtString)) { lrEditor.setRenewalAmt(float.Parse(renAmtString)); } string amtConsString = amtConsText.GetComponent <Text>().text; if (HelperValidator.validateFloatString(amtConsString)) { lrEditor.setAmtConsumedPerTime(float.Parse(amtConsString)); } // TODO: validate floats ( < 1) float prop; float.TryParse(propExtractText.GetComponent <Text>().text, out prop); lrEditor.setProportionExtracted(prop); ecoEditor.saveResource(); // saves to tentative resources }
/* add methods */ /// <param name="resourceName">Name of resource: used as key in dictionary.</param> public LandResourceEditor addResource(string resourceName) { lre = new LandResourceEditor(new ResourceStore(resourceName)); return(lre); }