diff --git a/Assets/Scripts/Forest.cs b/Assets/Scripts/Forest.cs index 2900ac7740441b0132a1a32665fa3602033cc574..cc8347eebf1a6f3d92be47f767e51297be5da037 100644 --- a/Assets/Scripts/Forest.cs +++ b/Assets/Scripts/Forest.cs @@ -20,7 +20,7 @@ public class Forest : Resource } } - public void refreshSprite() + public override void refreshSprite() { if (resources < 125) { @@ -70,22 +70,21 @@ public class Forest : Resource resources = Random.Range(50, 300); isForester = false; growthspeed = 1; + StartCoroutine("Grow"); } // Update is called once per frame void Update() { - checkExistence(); - StartCoroutine("Grow"); - refreshSprite(); + } IEnumerator Grow() { - yield return new WaitForSeconds(growthspeed); while (resources < 1000) { resources++; + yield return new WaitForSeconds(growthspeed); } } } diff --git a/Assets/Scripts/Resource.cs b/Assets/Scripts/Resource.cs index 0d341266ed5b7b091cf27f19b858719f7eb6595e..12e2222176840903099736ceb30c8c6e9d458faf 100644 --- a/Assets/Scripts/Resource.cs +++ b/Assets/Scripts/Resource.cs @@ -24,17 +24,24 @@ public abstract class Resource : MonoBehaviour { int r = resources; resources = 0; + refreshSprite(); + checkExistence(); return r; } else { resources = resources - amount; + refreshSprite(); + checkExistence(); return amount; } } + public abstract void refreshSprite(); + + + - public abstract void checkExistence(); }