From 23aef899172adfa21d277374d4657a02adcba245 Mon Sep 17 00:00:00 2001
From: Petteri <jupean@utu.fi>
Date: Sun, 3 Mar 2019 19:50:06 +0200
Subject: [PATCH] outcrop changes

---
 Assets/Scripts/Resources/Outcrop.cs | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/Assets/Scripts/Resources/Outcrop.cs b/Assets/Scripts/Resources/Outcrop.cs
index 83bed57..27d1cf8 100644
--- a/Assets/Scripts/Resources/Outcrop.cs
+++ b/Assets/Scripts/Resources/Outcrop.cs
@@ -8,13 +8,13 @@ public class Outcrop : MonoBehaviour
     [SerializeField]
     private int wood;
 
-    private int woodNeeded = 100;
+    private readonly int woodNeeded = 100;
 
     [SerializeField]
-    private GameObject quarry;
+    private GameObject quarry =null;
 
     [SerializeField]
-    private Resource neededResource;
+    private Resource neededResource =null;
 
     public Resource getNeededResource()
     {
@@ -28,12 +28,12 @@ public class Outcrop : MonoBehaviour
 
     public void setAmount(int amount)
     {
-        wood += amount;
+        wood = amount;
     }
 
     public void checkExistence()
     {
-        if (getAmount() >= 100)
+        if (getAmount() >= woodNeeded)
         {
             GameObject go = Instantiate<GameObject>(quarry);
             go.transform.position = this.transform.position;
@@ -45,12 +45,11 @@ public class Outcrop : MonoBehaviour
     {
         setAmount(getAmount() + amount);
         checkExistence();
-        woodNeeded -= getAmount();
     }
 
     public int stillNeeded()
     {
-        return woodNeeded;
+        return woodNeeded-wood;
     }
 
     // Start is called before the first frame update
-- 
GitLab