projectEli/Assets/Inventory System/Scripts/UI/LimitStackSlot.cs

57 lines
1.4 KiB
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2023-03-13 12:05:53 +00:00
using TMPro;
namespace SimpleInventorySystem
{
public class LimitStackSlot : MonoBehaviour
{
[HideInInspector] public SlotUI Slot;
//public int Weight;
//[HideInInspector] public LimitStackSlotManager limitStackSlotCapacities;
[HideInInspector] public LimitStackItemManager limitStackItemManager;
2023-03-13 12:05:53 +00:00
[HideInInspector] public int Count;
public TextMeshProUGUI CountText;
2023-03-13 12:05:53 +00:00
public void SetCount()
{
Count = Slot.stackedItems.Count;
CountText.text = Count.ToString();
}
public void Increment(ItemUI itemUI)
{
limitStackItemManager.Increment(itemUI);
2023-03-13 12:05:53 +00:00
SetCount();
}
public void Decrement(ItemUI itemUI)
{
limitStackItemManager.Decrement(itemUI);
2023-03-13 12:05:53 +00:00
SetCount();
}
public bool HasReachedLimit(ItemUI itemUI)
{
return limitStackItemManager.itemUI.WillExceedMaximumCapacity(itemUI.NestCapacityWeight);
}
private void Awake()
{
Slot = GetComponent<SlotUI>();
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
}