public void InitDemand(float scale) { _economyManager = GameObject.Find("Universe").GetComponent <EconomyManager>(); _maxGoods = _economyManager.MaxGoods; _stock = GetComponent <Stock>(); _demand = new Dictionary <string, Demand>(); _scale = scale; _numDemandedGoods = Mathi.Clamp((int)(UnityEngine.Random.value * scale), 2, _maxGoods); for (int i = 0; i < _numDemandedGoods; ++i) { Resource desc = _economyManager.GetRandomResource(); Demand demand; demand.Description = desc; demand.Consumed = (_scale * UnityEngine.Random.value * desc.Probability); if (!_demand.ContainsKey(demand.Description.ID)) { _demand.Add(demand.Description.ID, demand); } } }
public void InitProduction(float capability) { _economyManager = GameObject.Find("Universe").GetComponent <EconomyManager>(); _stock = GetComponent <Stock>(); _maxGoods = _economyManager.MaxGoods; _producedGoodTypes = new List <Production>(); _capability = capability; foreach (Resource desc in Resource.All.Values) { if (UnityEngine.Random.value * (1 - capability) <= desc.Probability) { Production prod; prod.Description = desc; prod.Produced = capability * desc.Probability * UnityEngine.Random.value; _producedGoodTypes.Add(prod); } } while (_producedGoodTypes.Count > _maxGoods) { _producedGoodTypes.RemoveAt((int)(UnityEngine.Random.value) * _producedGoodTypes.Count); } }
public void Init() { _economyManager = GameObject.Find("Universe").GetComponent <EconomyManager>(); _stock = new Dictionary <string, StoredResource>(); _stockLimits = new Dictionary <string, float>(); }