public void createUnit(Unit unit) { if (productionQueue.Count < 24) { // If not returned by now, resources are available productionQueue.Enqueue(unit); } else { print("Queue is full!"); return; } foreach (ResourceCost rc in unit.resourceCosts) { // Determine amounts int requiredAmount = rc.cost; int currentAmount = resourcesManager.getResource(rc.type).currentAmount; // Determine is current amount is enough if ((currentAmount - requiredAmount) < 0) { // Not enough resources Debug.Log("Not enough " + rc.type + " to create " + unit.unitName); return; } else { // Reduce resource by cost amounts resourcesManager.DecreaseResource(rc.type, rc.cost); } } }