Foerming/Assets/Scripts/InventorySlot.cs
d-hain aacdd80fdf added Inventory UI
added logic to inventory
 * it is very possible to be reworked in the near future
 * With
   - ScriptableItem
   - an own Inventory class maybe
   - if necessary no Dictionary anymore
2022-05-19 02:30:21 +02:00

30 lines
No EOL
602 B
C#

using UnityEngine;
using UnityEngine.UI;
public class InventorySlot : MonoBehaviour {
public Image icon;
private Item item;
public void addItem(Item newItem) {
item = newItem;
icon.sprite = item.defaultSprite;
icon.enabled = true;
}
public void clearSlot() {
item = null;
icon.sprite = null;
icon.enabled = false;
}
public void removeItem() {
PlayerController.instance.inventory.Remove(item);
}
public void useItem() {
//TODO: use item
Debug.Log("using " + item.displayName);
}
}