This commit is contained in:
j.mei7
2022-02-22 21:31:04 +01:00
parent 7d055be8d1
commit f5f3154c95
12 changed files with 231 additions and 134 deletions

View File

@@ -81,14 +81,17 @@ public class PlayerInteraction : MonoBehaviour
break;
case Interactable.InteractionType.Harvest:
Harvestable harvestable = interactable.GetComponent<Harvestable>();
ToolItem toolItem = (ToolItem)InventoryController.PlayerInstance.GetSelectedSlot().GetItem();
bool isCorrectTool = (toolItem != null && toolItem.toolType == harvestable.toolType);
if (Input.GetButton("Interact") && interactable.isInRange())
if (Input.GetButton("Interact") && interactable.isInRange() && isCorrectTool)
{
harvestable.IncreaseHarvestTime();
if (harvestable.GetHarvestTime() >= harvestable.GetHarvestDuration())
{
harvestable.Interact();
harvestable.ResetHarvestTime();
}
}
break;