This commit is contained in:
brausjonas
2022-05-16 05:08:37 +02:00
parent 460ab5c9e8
commit 06c8fcc061
29 changed files with 2788 additions and 35 deletions
@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Hotbar : MonoBehaviour
{
[SerializeField] private Image[] itemSlots;
[SerializeField] private Sprite[] itemIcons; //id always: -1 to get item icon
[SerializeField] private GameObject highlight;
private byte[] hotBarItems = new byte[9];
private byte selectedSlot = 0;
private void Start()
{
//change later:
for (int i = 0; i < 9; i++)
{
itemSlots[i].sprite = itemIcons[i];
hotBarItems[i] = (byte)(i + 1);
}
}
public void SelectSlot(byte idx)
{
selectedSlot = idx;
highlight.transform.position = itemSlots[idx].transform.position;
}
public byte GetSelectedSlot()
{
return selectedSlot;
}
public byte GetSelectedItemID()
{
return hotBarItems[selectedSlot];
}
}