mirror of
https://github.com/DerTyp7/example-top-down-unity.git
synced 2025-10-30 12:57:08 +01:00
tool
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user