2022-11-06 02:28:29 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2023-03-13 12:05:53 +00:00
|
|
|
|
using TMPro;
|
2022-11-06 02:28:29 +00:00
|
|
|
|
|
|
|
|
|
namespace SimpleInventorySystem
|
|
|
|
|
{
|
|
|
|
|
public class LimitStackSlot : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[HideInInspector] public SlotUI Slot;
|
2023-03-13 10:25:15 +00:00
|
|
|
|
//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;
|
2022-11-06 02:28:29 +00:00
|
|
|
|
|
2023-03-13 12:05:53 +00:00
|
|
|
|
public void SetCount()
|
|
|
|
|
{
|
|
|
|
|
Count = Slot.stackedItems.Count;
|
|
|
|
|
CountText.text = Count.ToString();
|
|
|
|
|
}
|
2023-03-13 10:25:15 +00:00
|
|
|
|
|
|
|
|
|
public void Increment(ItemUI itemUI)
|
2022-11-06 02:28:29 +00:00
|
|
|
|
{
|
2023-03-13 10:25:15 +00:00
|
|
|
|
limitStackItemManager.Increment(itemUI);
|
2023-03-13 12:05:53 +00:00
|
|
|
|
SetCount();
|
2022-11-06 02:28:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 10:25:15 +00:00
|
|
|
|
public void Decrement(ItemUI itemUI)
|
2022-11-06 02:28:29 +00:00
|
|
|
|
{
|
2023-03-13 10:25:15 +00:00
|
|
|
|
limitStackItemManager.Decrement(itemUI);
|
2023-03-13 12:05:53 +00:00
|
|
|
|
SetCount();
|
2022-11-06 02:28:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 10:25:15 +00:00
|
|
|
|
public bool HasReachedLimit(ItemUI itemUI)
|
2022-11-06 02:28:29 +00:00
|
|
|
|
{
|
2023-03-13 10:25:15 +00:00
|
|
|
|
return limitStackItemManager.itemUI.WillExceedMaximumCapacity(itemUI.NestCapacityWeight);
|
2022-11-06 02:28:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
Slot = GetComponent<SlotUI>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|