diff --git a/Assets/Scripts/City.cs b/Assets/Scripts/City.cs index 5c15fd42f74b8734254cc70500db19980c243ada..f0a557f6a59db14d08d358cc062752b8acf08cb2 100644 --- a/Assets/Scripts/City.cs +++ b/Assets/Scripts/City.cs @@ -5,7 +5,24 @@ using UnityEngine; public class City : MonoBehaviour { - + [SerializeField] + GameObject worker; + + [SerializeField] + public int population = 0; + + [SerializeField] + public int populationLevel = 0; + + [SerializeField] + public int resourcePoolLevel = 0; + + [SerializeField] + public int roadLevel = 0; + + [SerializeField] + public int collectorLevel = 0; + // Start is called before the first frame update void Start() @@ -15,12 +32,30 @@ public class City : MonoBehaviour public int GetLevel(UpgradeTargets target) { + switch (target) + { + case UpgradeTargets.population: + return this.populationLevel; + case UpgradeTargets.capacity: + return this.resourcePoolLevel; + case UpgradeTargets.speed: + return this.roadLevel; + case UpgradeTargets.collector: + return this.collectorLevel; + default: + Debug.Log("Default"); + return -1; + break; + } return 1; } public void AddCollector() { - + + GameObject go = Instantiate<GameObject>(worker); + + go.transform.position = new Vector3(); } @@ -46,7 +81,7 @@ public class City : MonoBehaviour public void AddPopulation(int v) { - + this.population += v; } @@ -87,9 +122,15 @@ public class City : MonoBehaviour { lista[i].SetCapacity(x); } + this.resourcePoolLevel++; } public void UseResources(List<int> a) { - + ResourcePool[] lista = gameObject.GetComponents<ResourcePool>(); + + for (int i = 0; i < lista.Length; i++) + { + UseResource(lista[i].GetResource(), a[0]); + } } } diff --git a/Assets/Scripts/ResourcePool.cs b/Assets/Scripts/ResourcePool.cs index c4cbf61147739be198f48ba6e87b14d6e506c870..95dc991eb61991d9dfeceba305f49af626ea1233 100644 --- a/Assets/Scripts/ResourcePool.cs +++ b/Assets/Scripts/ResourcePool.cs @@ -59,8 +59,5 @@ public class ResourcePool : MonoBehaviour { this.maxCapacity += x; } - public void AddCollector() - { - Collector c = gameObject.AddComponent<Collector>(); - } + }