Finish production line logic

This commit is contained in:
2024-08-18 17:03:09 +02:00
parent 67c6597c21
commit a7fd4a2fb1
21 changed files with 2558 additions and 736 deletions

View File

@@ -4,6 +4,7 @@ using UnityEngine;
public class HouseManager : MonoBehaviour
{
[SerializeField]
private float ttnw = 30; //Time to next worker
private float currentTtnw = 0;
private int workerPerHouse = 3;
@@ -23,9 +24,12 @@ public class HouseManager : MonoBehaviour
} else
{
currentTtnw = ttnw;
if (gameManager.GetResource(Resource.WORKER) < gameManager.GetResource(Resource.HOUSE) * workerPerHouse)
if (gameManager.GetResource(Resource.TOTAL_WORKER) < gameManager.GetResource(Resource.HOUSE) * workerPerHouse)
{
gameManager.AddResource(Resource.WORKER, 1);
int freeWorkerSlots = (gameManager.GetResource(Resource.HOUSE) * workerPerHouse) - gameManager.GetResource(Resource.TOTAL_WORKER);
int newWorkers = Mathf.CeilToInt((float)freeWorkerSlots / workerPerHouse);
gameManager.AddResource(Resource.WORKER, newWorkers);
gameManager.AddResource(Resource.TOTAL_WORKER, newWorkers);
}
}
}