45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
|
|
public class InventoryPanelController : MonoBehaviour {
|
|
|
|
[SerializeField] public GameObject inventorySlot;
|
|
[SerializeField] public Transform gridLayout;
|
|
|
|
[SerializeField] public TextMeshProUGUI enhancementAmount1;
|
|
[SerializeField] public TextMeshProUGUI enhancementAmount2;
|
|
[SerializeField] public TextMeshProUGUI enhancementAmount3;
|
|
|
|
private List<GameObject> slots;
|
|
|
|
// Start is called before the first frame update
|
|
private void Awake() {
|
|
slots = new List<GameObject>();
|
|
for (int i = 0; i < State.state.inventory.inventoryMaxSize; i++) {
|
|
GameObject slot = Instantiate(inventorySlot);
|
|
InventorySlotController slotController = slot.GetComponent<InventorySlotController>();
|
|
slotController.Refresh(i);
|
|
slotController.transform.SetParent(gridLayout.transform);
|
|
slotController.inventoryPanel = transform;
|
|
slotController.isIndexedInventoryItem = true;
|
|
slots.Add(slot);
|
|
}
|
|
updateEnhancementMaterialAmounts();
|
|
}
|
|
|
|
public void updateEnhancementMaterialAmounts() {
|
|
enhancementAmount1.SetText(State.state.inventory.material[0].ToString());
|
|
enhancementAmount2.SetText(State.state.inventory.material[1].ToString());
|
|
enhancementAmount3.SetText(State.state.inventory.material[2].ToString());
|
|
}
|
|
|
|
public void RefreshAll() {
|
|
for (int i = 0; i < slots.Count; i++) {
|
|
slots[i].GetComponent<InventorySlotController>().Refresh(i);
|
|
}
|
|
updateEnhancementMaterialAmounts();
|
|
}
|
|
}
|