public float determineCanProduce(MyEnum.Goods good, Nation player) { Dictionary <string, float> costs = ProductionCosts.GetCosts(good); float bottleNeck = 1000f; float nextComponent = 0.0f; float ratio; float materialMod = DetermineMaterialMod(player); foreach (string item in costs.Keys) { if (Enum.IsDefined(typeof(MyEnum.Goods), item)) { MyEnum.Goods itemType = (MyEnum.Goods)System. Enum.Parse(typeof(MyEnum.Goods), item); nextComponent = player.getNumberGood(itemType) * materialMod; ratio = nextComponent / costs[item]; } else { MyEnum.Resources itemType = (MyEnum.Resources)System. Enum.Parse(typeof(MyEnum.Resources), item); nextComponent = player.getNumberResource(itemType) * materialMod; ratio = nextComponent / costs[item]; } if (ratio < bottleNeck) { bottleNeck = ratio; } } int value = 0; int factoryLevel = getFactoryLevel(good); if (factoryLevel == 0) { value = 0; } if (factoryLevel == 1) { value = (int)Math.Min(4, bottleNeck); } if (factoryLevel == 2) { value = (int)Math.Min(8, bottleNeck); } float corruptionFactor = PlayerCalculator.getCorruptionFactor(player); float industrialExpFactor = PlayerCalculator.getIndustrialExperienceFactor(player); /*Later additional modifiers will affect this including: * Corruptuon, happiness, management level, and perhaps some * technologies */ value = (int)(value * corruptionFactor * industrialExpFactor); return(value); }
public void returnGoodsMaterial(MyEnum.Goods good, Nation player) { Dictionary <string, float> costs = ProductionCosts.GetCosts(good); foreach (string item in costs.Keys) { if (Enum.IsDefined(typeof(MyEnum.Goods), item)) { MyEnum.Goods itemType = (MyEnum.Goods)System. Enum.Parse(typeof(MyEnum.Goods), item); player.collectGoods(itemType, costs[item]); } else { MyEnum.Resources itemType = (MyEnum.Resources)System. Enum.Parse(typeof(MyEnum.Resources), item); player.collectResource(itemType, costs[item]); } } }
public void consumeGoodsMaterial(MyEnum.Goods good, Nation player) { Debug.Log("Consume materials for " + good.ToString()); Dictionary <string, float> costs = ProductionCosts.GetCosts(good); foreach (string item in costs.Keys) { if (Enum.IsDefined(typeof(MyEnum.Goods), item)) { MyEnum.Goods itemType = (MyEnum.Goods)System. Enum.Parse(typeof(MyEnum.Goods), item); player.consumeGoods(itemType, costs[item]); } else { MyEnum.Resources itemType = (MyEnum.Resources)System. Enum.Parse(typeof(MyEnum.Resources), item); player.consumeResource(itemType, costs[item]); } } }
public void selectGoodType() { App app = UnityEngine.Object.FindObjectOfType <App>(); int humanIndex = app.GetHumanIndex(); Nation player = State.getNations()[humanIndex]; string type = button.name; goodImage.sprite = Resources.Load("FinishedGoods/" + type, typeof(Sprite)) as Sprite; MyEnum.Goods good = (MyEnum.Goods)System. Enum.Parse(typeof(MyEnum.Goods), type); int factoryLevel = player.industry.getFactoryLevel(good); factoryLevelText.text = "Factory Level: " + factoryLevel; goodType = good; confirmBuild.GetComponent <ComfirmManufacture>().good = good; upgradeButton.GetComponent <UpgradeFactoryButton>().good = good; int turn = State.turn; if (factoryLevel == 0) { productionLevelImage.sprite = Resources.Load("Sprites/workshop", typeof(Sprite)) as Sprite; } if (factoryLevel == 1) { productionLevelImage.sprite = Resources.Load("Sprites/factorySmall", typeof(Sprite)) as Sprite; } if (factoryLevel == 2) { productionLevelImage.sprite = Resources.Load("Sprites/FactoryBig") as Sprite; } bool upgradeCheck = player.industry.CheckIfCanUpgradeFactory(good); if (upgradeCheck == true) { Debug.Log("Can upgrade"); upgradeButton.interactable = true; } else { Debug.Log("Cannot upgrade"); upgradeButton.interactable = false; } inventory.text = "Current Inventory: " + player.getNumberGood(good).ToString(); currentPrice.text = "Current Price: " + State.market.getPriceOfGood(good); Dictionary <string, float> inputString = ProductionCosts.GetCosts(good); string itemCosts = ""; foreach (string item in inputString.Keys) { itemCosts = itemCosts + " " + item + " " + inputString[item].ToString() + ","; } itemCosts = itemCosts.Remove(itemCosts.Length - 1, turn); input.text = "Input: " + itemCosts; float ableToProduce = player.industry.determineCanProduce(good, player); canProduce.text = "Able to Produce: " + ableToProduce.ToString(); slider.maxValue = (float)Math.Floor(ableToProduce); slider.value = 0; Debug.Log("Max slider value: " + slider.maxValue); if (slider.maxValue >= 1) { slider.interactable = true; } confirmBuild.interactable = false; }