From ea6c9887b7fc082ae6f3a3fd84bc02697a0ccc96 Mon Sep 17 00:00:00 2001 From: Kimi Heinonen <kimiheinonen@hotmail.com> Date: Sun, 3 Mar 2019 11:14:25 +0200 Subject: [PATCH] Worker lisatty city prefabiin --- Assets/Prefab/City.prefab | 3 ++- Assets/Scripts/City.cs | 18 +++++++++++++++--- Assets/Scripts/ResourcePool.cs | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Assets/Prefab/City.prefab b/Assets/Prefab/City.prefab index 6c91e34..c2b9030 100644 --- a/Assets/Prefab/City.prefab +++ b/Assets/Prefab/City.prefab @@ -119,7 +119,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: dfe928a858872424991e927606dd4bc3, type: 3} m_Name: m_EditorClassIdentifier: - worker: {fileID: 0} + workerlista: [] + worker: {fileID: 548039319383633024, guid: 7dc194a2047a39340a91ca7636a56290, type: 3} population: 0 populationLevel: 0 resourcePoolLevel: 0 diff --git a/Assets/Scripts/City.cs b/Assets/Scripts/City.cs index f0a557f..70cde61 100644 --- a/Assets/Scripts/City.cs +++ b/Assets/Scripts/City.cs @@ -5,6 +5,9 @@ using UnityEngine; public class City : MonoBehaviour { + [SerializeField] + List<GameObject> workerlista; + [SerializeField] GameObject worker; @@ -20,16 +23,18 @@ public class City : MonoBehaviour [SerializeField] public int roadLevel = 0; - [SerializeField] - public int collectorLevel = 0; // Start is called before the first frame update void Start() { + } + /** + * Palauttaa kysytyn targetin levelin + */ public int GetLevel(UpgradeTargets target) { switch (target) @@ -41,7 +46,7 @@ public class City : MonoBehaviour case UpgradeTargets.speed: return this.roadLevel; case UpgradeTargets.collector: - return this.collectorLevel; + return this.workerlista.Count; default: Debug.Log("Default"); return -1; @@ -50,12 +55,19 @@ public class City : MonoBehaviour return 1; } + /** + * Lisaa uuden collecotrin + */ public void AddCollector() { GameObject go = Instantiate<GameObject>(worker); + this.workerlista.Add(go); go.transform.position = new Vector3(); + + + this.population++; } diff --git a/Assets/Scripts/ResourcePool.cs b/Assets/Scripts/ResourcePool.cs index 95dc991..d09e1d3 100644 --- a/Assets/Scripts/ResourcePool.cs +++ b/Assets/Scripts/ResourcePool.cs @@ -59,5 +59,9 @@ public class ResourcePool : MonoBehaviour { this.maxCapacity += x; } + public int GetMaxCapacity() + { + return this.maxCapacity; + } } -- GitLab