From a635c3222cc1a79c0251fa4af805cd002a6eac9e Mon Sep 17 00:00:00 2001
From: Erno Lokkila <eolokk@utu.fi>
Date: Sun, 3 Mar 2019 19:59:48 +0200
Subject: [PATCH] Ground generator not generates first worker correctly
---
Assets/Scripts/GroundGenerator/GroundGenerator.cs | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/Assets/Scripts/GroundGenerator/GroundGenerator.cs b/Assets/Scripts/GroundGenerator/GroundGenerator.cs
index 0121597..f454c49 100644
--- a/Assets/Scripts/GroundGenerator/GroundGenerator.cs
+++ b/Assets/Scripts/GroundGenerator/GroundGenerator.cs
@@ -13,8 +13,6 @@ public class GroundGenerator : MonoBehaviour
private GameObject[] resourceGOs = null;
[SerializeField]
private GameObject homeGO = null;
- [SerializeField]
- private GameObject workerGO = null;
private int food = 2;
private int stone = 3;
@@ -63,15 +61,15 @@ public class GroundGenerator : MonoBehaviour
if (Random.value < 0.10f)
{
- ground[x, y] = 2;
+ ground[x, y] = wood;
}
if (Random.value < 0.10f)
{
- ground[x, y] = 3;
+ ground[x, y] = stone;
}
if (Random.value < 0.10f)
{
- ground[x, y] = 4;
+ ground[x, y] = food;
}
}
void createGround()
@@ -150,8 +148,8 @@ public class GroundGenerator : MonoBehaviour
private void createHome() {
ground[ground.GetLength(0) / 2, ground.GetLength(1) / 2] = home;
- spawn(homeGO, houseCoords[0], houseCoords[1], houseDepth);
- homeGO.GetComponent<City>().AddCollector();
+ GameObject go = spawn(homeGO, houseCoords[0], houseCoords[1], houseDepth);
+ go.GetComponent<City>().AddCollector();
}
private GameObject spawn(GameObject go, int x, int y, int z) {
return Instantiate<GameObject>(go, new Vector3(x, y, z), Quaternion.identity);
--
GitLab