Skip to content
Snippets Groups Projects
Commit a5cd597a authored by Leevi Grönlund's avatar Leevi Grönlund
Browse files

Resources some updates.

parent 521069d5
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
}
......@@ -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();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment