mirror of
https://github.com/DerTyp7/harvestdale-unity.git
synced 2025-10-30 21:17:09 +01:00
sfdagsghds
This commit is contained in:
@@ -9,7 +9,7 @@ public class PlayerController : MonoBehaviour
|
||||
public static Action OnActiveSlotChanged;
|
||||
public Item testItem1;
|
||||
public Item testItem2;
|
||||
|
||||
public float interactionDistance = 2.5f;
|
||||
public int hotbarSlotCount = 9;
|
||||
public int activeHotbarSlot = 0;
|
||||
[SerializeField] private Inventory playerInventory;
|
||||
@@ -44,6 +44,26 @@ public class PlayerController : MonoBehaviour
|
||||
GuiManager.Instance.TogglePanel("Inventory");
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Vector3Int snappedMousePosition = GridBuildingSystem.Instance.GetSnappedMousePosition();
|
||||
Vector3Int snappedPlayerPosition = GridBuildingSystem.Instance.GetSnappedPosition(gameObject.transform.position);
|
||||
if (Vector3Int.Distance(snappedMousePosition, snappedPlayerPosition) <= interactionDistance)
|
||||
{
|
||||
if (playerInventory.items[activeHotbarSlot]?.item is Tool)
|
||||
{
|
||||
Tool tool = playerInventory.items[activeHotbarSlot].item as Tool;
|
||||
tool.Use();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Not in range");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//! DEBUG
|
||||
if (Input.GetKeyDown(KeyCode.U))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user