diff --git a/Assets/Prefab/City.prefab b/Assets/Prefab/City.prefab index 6c91e34f17e754063f08bbcfdc508bc951df9b02..c2b9030c0db9493c59dd7071cf9b030a85f03444 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 f0a557f6a59db14d08d358cc062752b8acf08cb2..70cde618b91a0c1e7c726ddcddb0d00a1343a741 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/Collector.cs b/Assets/Scripts/Collector.cs index 8279847034f59630778e7570d5baa94d33a9a64f..d772789090ed0174bacc40f72d1e189363aabf1e 100644 --- a/Assets/Scripts/Collector.cs +++ b/Assets/Scripts/Collector.cs @@ -53,7 +53,7 @@ public class Collector : MonoBehaviour MoveTo(hit.collider.gameObject); } } - if (target != null) + if (move_to != null) transform.position = Vector3.MoveTowards(new Vector3(transform.position.x, transform.position.y, -1f), move_to.transform.position, speed * Time.deltaTime); } private void OnTriggerEnter2D(Collider2D collision) @@ -67,7 +67,7 @@ public class Collector : MonoBehaviour this.resource = this.target.GetComponent<Resource>(); StartCoroutine("goHome"); } - else if (collision.gameObject.name == "City" && this.resource != null) + else if (collision.gameObject.tag == "Home" && this.resource != null) { //resets amount and resource variables collision.gameObject.GetComponent<City>().AddResource(this.resource, this.amount); diff --git a/Assets/Scripts/EventSystem/EventSystem.cs b/Assets/Scripts/EventSystem/EventSystem.cs index 0762879b792341ea32064fd4bc3e843a116b543d..8726731684a1ccf61644067348375e23738dc26b 100644 --- a/Assets/Scripts/EventSystem/EventSystem.cs +++ b/Assets/Scripts/EventSystem/EventSystem.cs @@ -15,9 +15,12 @@ public static class EventSystem public static void EventHappened(EventType name) { + Debug.Log("happened"); if (events.ContainsKey(name)) { - foreach (IAction e in events.Values){ + + Debug.Log("contains: "+events.Values.ToString()); + foreach (IAction e in events[name]){ e.React(name); } } diff --git a/Assets/Scripts/ResourcePool.cs b/Assets/Scripts/ResourcePool.cs index 95dc991eb61991d9dfeceba305f49af626ea1233..d09e1d331c3347873579f40640e86d0fba171f94 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; + } } diff --git a/Assets/Sprites/rock.png b/Assets/Sprites/rock.png index 70357492f04c41dd55cfd07c2168f1f0a0f6d561..d206a18a5b790bc7c7629bf9103d6d7bcc28b737 100644 Binary files a/Assets/Sprites/rock.png and b/Assets/Sprites/rock.png differ