mirror of
https://github.com/DerTyp7/example-top-down-unity.git
synced 2025-10-30 21:07:09 +01:00
tool
This commit is contained in:
@@ -4,35 +4,39 @@ using UnityEngine;
|
||||
|
||||
public class InventoryController : MonoBehaviour
|
||||
{
|
||||
/*[SerializeField] Item item1;// not needed
|
||||
[SerializeField] Item item2;// not needed
|
||||
public Inventory inventory;
|
||||
[SerializeField] UI_Inventory uiInventory;
|
||||
private void Awake()
|
||||
{
|
||||
inventory = transform.GetComponent<Inventory>();
|
||||
inventory.createEmptyInventory(8,10);
|
||||
|
||||
inventory.addItemAt(0, item1, 8);
|
||||
inventory.addItemAt(0, item1, 1);
|
||||
inventory.addItemAt(3, item2, 15);
|
||||
inventory.addItemAt(4, item1, 3);
|
||||
[SerializeField]
|
||||
int selectedSlotIndex;
|
||||
|
||||
Debug.Log(inventory.addItemAt(0, item2, 15));
|
||||
Debug.Log(inventory.getInventory[0].Count);
|
||||
Debug.Log(inventory.removeItemAt(0, 10));
|
||||
Debug.Log(inventory.getInventory[0].Count);
|
||||
|
||||
uiInventory.setInventory(inventory);
|
||||
Inventory inventory;
|
||||
|
||||
public static InventoryController PlayerInstance { get; private set; }
|
||||
|
||||
public Slot GetSelectedSlot()
|
||||
{
|
||||
return inventory.GetInventory()[selectedSlotIndex];
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
|
||||
PlayerInstance = this;
|
||||
inventory = Inventory.PlayerInstance;
|
||||
selectedSlotIndex = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}*/
|
||||
if (Input.GetAxis("Mouse ScrollWheel") < 0)
|
||||
{
|
||||
if (inventory.IndexIsInRange(selectedSlotIndex - 1))
|
||||
{
|
||||
selectedSlotIndex -= 1;
|
||||
}
|
||||
}
|
||||
if (Input.GetAxis("Mouse ScrollWheel") > 0)
|
||||
{
|
||||
if (inventory.IndexIsInRange(selectedSlotIndex + 1))
|
||||
{
|
||||
selectedSlotIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user