private void Update() { float baseDays = ResourcesDatabase.GetBaseDays(ItemName); float localProductivity = ProductivityController.GetAverageProductivityHere(ItemName); float globalProductivity = ProductivityController.GetAverageProductivityEverywhere(ItemName); daysWorldWide.text = Mathf.RoundToInt(baseDays / globalProductivity) + " days"; daysLocal.text = localProductivity > 0 ? "(" + Mathf.RoundToInt(baseDays / localProductivity) + " days here)" : "(??? days here)"; ItemOrder io = new ItemOrder(100, ItemName); valueLabel.text = MoneyController.symbol + io.ExchangeValue().ToString("n2"); }
public static float GetBasePrice(string item, int amount) { if (!resourceData.ContainsKey(item)) { Debug.LogError("ResourceDatabase does not contain " + item); } float baseDays = resourceData[item].days; float globalProductivity = ProductivityController.GetAverageProductivityEverywhere(item); float price = baseDays * PoundsPerDays / globalProductivity; price = (float)Math.Round(price, 2); float ingredientsPrice = 0; //add the ingredients which go into the production of this item foreach (string s in resourceData[item].ingredients) { string[] data = s.Split(' '); int amount2 = (int)(float.Parse(data[0])); //amount / 100f needed to account for when the amount of what's being valued is not 100; preserve the ratio string item2 = data[1]; if (string.IsNullOrEmpty(item2)) { Debug.LogError(item + " has a null ingredient"); } ingredientsPrice += GetBasePrice(item2, amount2); } //SOMEHOW DETERMINE WHAT CONSTANT CAPITAL (STEEL, WOOD, COAL, ETC) IS BEING INVESTED INTO THE PRODUCTION OF THE ITEM // ADD THIS AVERAGE VALUE TO THE VALUE OF THE COMMODITY // BC EACH BUILDING HAS A CONSTANT VALUE OF MACHINERY AND FUEL INVESTED INTO EACH UNIT OF PRODUCTION, THIS SHOULDN'T BE TOO HARD // EXCEPT THAT WE HAVE TO SURVEY EACH BUILDING TO FIGURE OUT WHAT MACHINERY AND FUEL IS USED price += ingredientsPrice / 100f; price += ProductivityController.GetAverageAutomationEverywhere(item) / 100f; return(price * amount); }