diff --git a/Assets/Scripts/Upgrades/CollectorUpgrade.cs b/Assets/Scripts/Upgrades/CollectorUpgrade.cs index b5c72f59933ba0c139219c9f346d9d29979241e8..698c69f81df2271713aa2f59445cbd456d772dcb 100644 --- a/Assets/Scripts/Upgrades/CollectorUpgrade.cs +++ b/Assets/Scripts/Upgrades/CollectorUpgrade.cs @@ -22,7 +22,11 @@ public class CollectorUpgrade : Upgrade UpgradeTargets target = UpgradeTargets.collector; City city = gameObject.GetComponent<City>(); int currentLevel = city.GetLevel(target); - city.UseResources(GetPrices(currentLevel)); - city.AddCollector(); + + if (currentLevel <= city.GetLevel(UpgradeTargets.city) * maxLevelModifier) + { + city.UseResources(GetPrices(currentLevel)); + city.AddCollector(); + } } } diff --git a/Assets/Scripts/Upgrades/PopulationUpgrade.cs b/Assets/Scripts/Upgrades/PopulationUpgrade.cs index fbda2c4c702dce9efee3713888199cbaffbb219e..f9fa3da07604c3e55aba3aaa0b2138978d2febe6 100644 --- a/Assets/Scripts/Upgrades/PopulationUpgrade.cs +++ b/Assets/Scripts/Upgrades/PopulationUpgrade.cs @@ -21,8 +21,12 @@ public class PopulationUpgrade : Upgrade UpgradeTargets target = UpgradeTargets.population; City city = gameObject.GetComponent<City>(); int currentLevel = city.GetLevel(target); - city.UseResources(GetPrices(currentLevel)); - city.AddPopulation(currentLevel * 10); - Debug.Log("population upgraded"); + + if (currentLevel <= city.GetLevel(UpgradeTargets.city) * maxLevelModifier) + { + city.UseResources(GetPrices(currentLevel)); + city.AddPopulation(currentLevel * 10); + Debug.Log("population upgraded"); + } } } diff --git a/Assets/Scripts/Upgrades/ResourceCapacityUpgrade.cs b/Assets/Scripts/Upgrades/ResourceCapacityUpgrade.cs index 45ac50727a3cc441d682695ee050eb0824668a57..3f17ea3427668157c75c22cb8f418d61ca06e607 100644 --- a/Assets/Scripts/Upgrades/ResourceCapacityUpgrade.cs +++ b/Assets/Scripts/Upgrades/ResourceCapacityUpgrade.cs @@ -21,9 +21,13 @@ public class ResourceCapacityUpgrade : Upgrade UpgradeTargets target = UpgradeTargets.capacity; City city = gameObject.GetComponent<City>(); int currentLevel = city.GetLevel(target); - city.UseResources((GetPrices(currentLevel))); - city.IncreaseCapacity(currentLevel * 100); - Debug.Log("Capacity upgraded"); + + if (currentLevel <= city.GetLevel(UpgradeTargets.city) * maxLevelModifier) + { + city.UseResources((GetPrices(currentLevel))); + city.IncreaseCapacity(currentLevel * 100); + Debug.Log("Capacity upgraded"); + } } } diff --git a/Assets/Scripts/Upgrades/ResourceEfficiencyUpgrade.cs b/Assets/Scripts/Upgrades/ResourceEfficiencyUpgrade.cs index 94cb070ee00f1601542f1e71b113f0a87d970a9a..ab8ee4ad8d5d365e71254840a757e27284d13cca 100644 --- a/Assets/Scripts/Upgrades/ResourceEfficiencyUpgrade.cs +++ b/Assets/Scripts/Upgrades/ResourceEfficiencyUpgrade.cs @@ -7,7 +7,7 @@ public class ResourceEfficiencyUpgrade : Upgrade // Start is called before the first frame update void Start() { - + maxLevelModifier = 5; } // Update is called once per frame @@ -19,8 +19,11 @@ public class ResourceEfficiencyUpgrade : Upgrade public void UpgradeEfficiency() { City city = gameObject.GetComponent<City>(); - IncreaseEfficiencyLevel(); - city.UseResources(GetPrices(GetEfficiencyLevel() * GetEfficiencyLevel())); - Debug.Log("Efficienfy upgraded to: " + GetEfficiencyLevel()); + if (GetEfficiencyLevel() <= maxLevelModifier) + { + IncreaseEfficiencyLevel(); + city.UseResources(GetPrices(GetEfficiencyLevel() * GetEfficiencyLevel())); + Debug.Log("Efficienfy upgraded to: " + GetEfficiencyLevel()); + } } } diff --git a/Assets/Scripts/Upgrades/RoadUpgrade.cs b/Assets/Scripts/Upgrades/RoadUpgrade.cs index 329ef10f69d2e2e2a93328e359d578c1982b7d42..6ef9e4daafc52f2d623ddcaed3cd1e86dc5d898e 100644 --- a/Assets/Scripts/Upgrades/RoadUpgrade.cs +++ b/Assets/Scripts/Upgrades/RoadUpgrade.cs @@ -22,10 +22,14 @@ public class RoadUpgrade : Upgrade UpgradeTargets target = UpgradeTargets.speed; Road road = gameObject.GetComponent<Road>(); City city = gameObject.GetComponent<City>(); - float currentLevel = road.GetLevel(target); - city.UseResources(GetPrices(currentLevel)); - road.IncreaseSpeed(1 / currentLevel); - Debug.Log("Road upgraded"); + int currentLevel = (int) road.GetLevel(target); + + if (currentLevel <= city.GetLevel(UpgradeTargets.city) * maxLevelModifier) + { + city.UseResources(GetPrices(currentLevel)); + road.IncreaseSpeed(1 / currentLevel); + Debug.Log("Road upgraded"); + } } } diff --git a/Assets/Scripts/Upgrades/Upgrade.cs b/Assets/Scripts/Upgrades/Upgrade.cs index 0dc875ab5c672895c4bd4ec0390efb3c67d89378..9bc13dc5d1fafcfc3df4ab2134527ff2e795af59 100644 --- a/Assets/Scripts/Upgrades/Upgrade.cs +++ b/Assets/Scripts/Upgrades/Upgrade.cs @@ -8,7 +8,12 @@ public abstract class Upgrade : MonoBehaviour private float efficiencyLevel = 1; - private Dictionary<Resources, int> resources = new Dictionary<Resources, int>(); + private Dictionary<Resource, int> resources = new Dictionary<Resource, int>() + { + { null , 1}, + { null , 1}, + { null , 0}, + }; // Start is called before the first frame update void Start() @@ -58,7 +63,7 @@ public abstract class Upgrade : MonoBehaviour public List<int> GetPrices(float modifier) { List<int> prices = new List<int>(); - foreach(KeyValuePair<Resources, int> key in resources) + foreach(KeyValuePair<Resource, int> key in resources) { prices.Add((int) (key.Value * modifier * 50 * GetEfficiency())); }