100 lines
2.5 KiB
C#
100 lines
2.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
|
|
namespace SimpleInventorySystem
|
|
{
|
|
public class LimitStackItemManager : MonoBehaviour
|
|
{
|
|
//public int StackItemLimit = 0;
|
|
//public int Count { get; private set; }
|
|
public LimitStackSlot[] limitStackSlots;
|
|
public bool combinedLimit = true;
|
|
//public TextMeshProUGUI capacityText;
|
|
public ItemUI itemUI;
|
|
public SlotUI slot;
|
|
|
|
private void Awake()
|
|
{
|
|
foreach (LimitStackSlot ls in limitStackSlots)
|
|
{
|
|
ls.limitStackItemManager = this;
|
|
}
|
|
|
|
//slot = GetComponent<SlotUI>();
|
|
|
|
//itemUI.limitStackItemCapacity.SetRenderItemUIPropertyValue();
|
|
}
|
|
|
|
public void SetStackSlotLimit(ItemUI item)
|
|
{
|
|
if(item == null)
|
|
{
|
|
Debug.LogWarning("LimitStackSlotManager: SetStackSlotLimit(ItemUI item): The passed item should not be null.");
|
|
return;
|
|
}
|
|
|
|
itemUI = item;
|
|
|
|
//StackItemLimit = item.limitStackItemCapacity.Capacity;
|
|
//Debug.Log($"StackSlotLimit: {StackItemLimit}");
|
|
|
|
//itemUI.limitStackItemCapacity.SetRenderItemUIPropertyValue();
|
|
}
|
|
|
|
public void UnsetStackSlotLimit()
|
|
{
|
|
//StackItemLimit = 0;
|
|
//Count = 0;
|
|
|
|
//itemUI.limitStackItemCapacity.SetRenderItemUIPropertyValue();
|
|
itemUI = null;
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
foreach (LimitStackSlot ls in limitStackSlots)
|
|
{
|
|
ls.limitStackItemManager = this;
|
|
}
|
|
slot.limitStackItemManager = this;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void Increment(ItemUI attachedItem)
|
|
{
|
|
if(itemUI != null)
|
|
{
|
|
itemUI.IncreaseCapacityCount(attachedItem);
|
|
}
|
|
}
|
|
public void Decrement(ItemUI attachedItem)
|
|
{
|
|
if (itemUI != null)
|
|
{
|
|
itemUI.DecreaseCapacityCount(attachedItem);
|
|
}
|
|
}
|
|
|
|
/*private LimitStackSlot GetLimitStackSlot(ItemUI item)
|
|
{
|
|
foreach (LimitStackSlot ls in limitStackSlots)
|
|
{
|
|
if(item == ls.itemUI)
|
|
{
|
|
return ls;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}*/
|
|
}
|
|
} |