public void TryUnlockPolicyTree() { int policyCost = PolicyCostLogic.GetCostOfNextPolicyForCiv(SelectedCiv); if ((IgnoreCost || SelectedCiv.CultureStockpile >= policyCost) && PolicyCanon.GetTreesAvailableFor(SelectedCiv).Contains(TreeToRecord) ) { SelectedCiv.CultureStockpile -= IgnoreCost ? 0 : policyCost; PolicyCanon.SetTreeAsUnlockedForCiv(TreeToRecord, SelectedCiv); } }
public override void Refresh() { if (PolicyTreeRecords == null) { SetUpPolicyTrees(); } if (ObjectToDisplay == null) { return; } foreach (var treeRecord in PolicyTreeRecords) { treeRecord.SelectedCiv = ObjectToDisplay; treeRecord.IgnoreCost = IgnoreCost; treeRecord.Refresh(); } CostSection.gameObject.SetActive(!IgnoreCost); if (!IgnoreCost) { int stockpile = ObjectToDisplay.CultureStockpile; int costForNext = PolicyCostLogic.GetCostOfNextPolicyForCiv(ObjectToDisplay); float cultureProduction = YieldLogic.GetYieldOfCivilization(ObjectToDisplay)[YieldType.Culture]; CultureStockpileField.text = stockpile.ToString(); CultureForNextPolicyField.text = costForNext.ToString(); if (stockpile >= costForNext) { TurnsUntilNextPolicyField.text = "(0 turns)"; } else if (cultureProduction == 0) { TurnsUntilNextPolicyField.text = "(-- turns)"; } else { TurnsUntilNextPolicyField.text = string.Format( "({0} turns)", Math.Max(0, Mathf.CeilToInt((costForNext - stockpile) / cultureProduction)) ); } } }