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
This commit is contained in:
d-hain 2022-05-19 02:30:21 +02:00
parent 433158e658
commit aacdd80fdf
103 changed files with 17775 additions and 58 deletions

View file

@ -0,0 +1,34 @@
using UnityEngine;
public class InventoryUI : MonoBehaviour {
public Transform itemsParent;
public GameObject inventoryUI;
private PlayerController playerController;
private InventorySlot[] slots;
// Start is called before the first frame update
void Start() {
playerController = PlayerController.instance;
playerController.onItemChangedCallback += updateUI;
slots = itemsParent.GetComponentsInChildren<InventorySlot>();
}
// Update is called once per frame
void Update() {
if(Input.GetButtonDown("Inventory")) {
inventoryUI.SetActive(!inventoryUI.activeSelf);
}
}
private void updateUI() {
for(int i = 0; i < slots.Length; i++) {
if(i < playerController.inventory.Count) {
// slots[i].addItem(playerController.inventory[i]); //TODO: dictionary "letztes" Item finden, Wie?!?!?!
} else {
slots[i].clearSlot();
}
}
}
}