public int Overpopulation(int year) { PopulationBuildingProperties properties = new PopulationBuildingProperties(); int normalPop = 0; int capacity = 0; foreach (Slot slot in GameMap.SlotList) { if (slot.ConstructionType == ConstructionType.Population) { if (slot.GetReservation(year) != null) { capacity = properties.MaxCapacity(slot.GetReservation(year).ConstructionName, slot.GetReservation(year).UpgradeYear, year); normalPop += capacity; } } } if (GetPopulation(year) - capacity > 0) { return((int)GetPopulation(year) - capacity); } else { return(0); } }
public int Overpopulation(int year) { PopulationBuildingProperties properties = new PopulationBuildingProperties(); int normalPop = 0; int capacity =0 ; foreach (Slot slot in GameMap.SlotList) { if (slot.ConstructionType == ConstructionType.Population) { if (slot.GetReservation(year) != null) { capacity = properties.MaxCapacity(slot.GetReservation(year).ConstructionName, slot.GetReservation(year).UpgradeYear, year); normalPop += capacity; } } } if (GetPopulation(year) - capacity > 0) { return (int)GetPopulation(year) - capacity; } else { return 0; } }
public void RefreshTooltip() { tooltipText = GetDescription(building); BuildingsBaseBonuses parameters = new BuildingsBaseBonuses(); BuildingsBaseProperties properties = new BuildingsBaseProperties(); PopulationBuildingProperties popProp = new PopulationBuildingProperties(); float Economy = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Economy; float Health = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Health; float Education = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Education; float Energy = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Energy; float Food = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Food; float Environment = parameters.BuildingMilleniumGoalSet(building, GameManager.CurrentYear).Environment; string pozitiveParams = ""; string negativeParams = ""; if (Economy > 0) pozitiveParams += "\n Economy +" + Economy.ToString(); else if (Economy < 0) negativeParams += "\n Economy -" + Economy.ToString(); if (Health > 0) pozitiveParams += "\n Health +" + Health.ToString(); else if (Health < 0) negativeParams += "\n Health -" + Health.ToString(); if (Education > 0) pozitiveParams += "\n Education +" + Education.ToString(); else if (Education < 0) negativeParams += "\n Education -" + Education.ToString(); if (Energy > 0) pozitiveParams += "\n Energy +" + Energy.ToString(); else if (Energy < 0) negativeParams += "\n Energy -" + Energy.ToString(); if (Food > 0) pozitiveParams += "\n Food +" + Food.ToString(); else if (Food < 0) negativeParams += "\n Food -" + Food.ToString(); if (Environment > 0) pozitiveParams += "\n Environment +" + Environment.ToString(); else if (Environment < 0) negativeParams += "\n Environment -" + Environment.ToString(); int price = properties.BuildingBaseProperties(building, GameManager.CurrentYear, 0, GameManager.CurrentYear).Price; bool canAfford = true; try { canAfford = (GameManager.GetMoney(GameManager.CurrentYear) >= price); } catch(Exception ex){} if (!canAfford) { //can afford tooltipText += "\n - CAN NOT AFFORD - "; tooltipText += pozitiveParams; tooltipText += negativeParams; } else //can not afford { tooltipText += "\n" + pozitiveParams; tooltipText += negativeParams; } tooltipText += "\nPrice: $" + price.ToString(); if (building == Construction.PopulationCity || building == Construction.PopulationMetropolis || building == Construction.PopulationTown || building == Construction.PopulationVillage) { tooltipText += "\nNormal capacity:\n " + popProp.MaxCapacity(building, GameManager.CurrentYear, GameManager.CurrentYear).ToString(); } }