public void takeTool(Tool tool, Citizen citizen) { if (toolsInventory.nbElementsTotal(tool) < toolsInventory.getLimit(tool) && citizen.toolsToTransport.nbElementsTotal(tool) > 0) { citizen.toolsToTransport.remove(tool); toolsInventory.add(tool); } askSupplyToConstruct(); if (enoughToolsToBuild) { needTools = false; } if (enoughConstructToBuild) { needRessources = false; } }
IEnumerator create(Tool tool, Building building) { isCraftingTool = true; for (int i = 0; i < tool.numberRessourcesNeeded; i++) { building.GetComponent <RessourceInventory>().remove(tool.ressourceNeeded); } ToolInventory toolInventoryBuilding = building.GetComponent <ToolInventory>(); toolInventoryBuilding.wood.text = (int.Parse(toolInventoryBuilding.wood.text) - toolInventoryBuilding.activeTool.numberRessourcesNeeded).ToString(); yield return(new WaitForSeconds(5.0f)); toolInventoryBuilding.addTool(); toolInventoryBuilding.add(tool); toolInventoryBuilding.toolCount.text = (int.Parse(toolInventoryBuilding.toolCount.text) + 1).ToString(); //toolInventoryBuilding.isCrafted(); //yield return new WaitForSeconds(1.0f); isCraftingTool = false; }