88 lines
2.8 KiB
C#
88 lines
2.8 KiB
C#
|
using System.Collections.Generic;
|
||
|
using Sirenix.OdinInspector;
|
||
|
using TMPro;
|
||
|
using UnityEngine;
|
||
|
|
||
|
// ReSharper disable once CheckNamespace
|
||
|
namespace BlueWaterProject
|
||
|
{
|
||
|
public class DiscardPopupUi : MonoBehaviour
|
||
|
{
|
||
|
private enum RemoveType
|
||
|
{
|
||
|
NONE = 0,
|
||
|
SINGLE,
|
||
|
MULTI
|
||
|
}
|
||
|
|
||
|
[SerializeField, Required] private TMP_Text contentText;
|
||
|
[SerializeField, Required] private TMP_Text countText;
|
||
|
[SerializeField, Required] private GameObject countSelectUi;
|
||
|
|
||
|
private List<ItemSlotUi> selectedList = new();
|
||
|
private int currentCount = 1;
|
||
|
private RemoveType removeType;
|
||
|
|
||
|
public void DiscardMessage(ItemSlotUi selectedSlot)
|
||
|
{
|
||
|
removeType = RemoveType.SINGLE;
|
||
|
selectedList.Clear();
|
||
|
selectedList.Add(selectedSlot);
|
||
|
contentText.text = ItemManager.Inst.ItemDictionary[selectedSlot.ItemSlot.Idx].name + "을(를) 버리시겠습니까?";
|
||
|
currentCount = 1;
|
||
|
countText.text = currentCount.ToString();
|
||
|
|
||
|
countSelectUi.SetActive(true);
|
||
|
gameObject.SetActive(true);
|
||
|
}
|
||
|
|
||
|
public void DiscardAllMessage(List<ItemSlotUi> selectedSlotList)
|
||
|
{
|
||
|
removeType = RemoveType.MULTI;
|
||
|
selectedList = new List<ItemSlotUi>(selectedSlotList);
|
||
|
contentText.text = "선택한 물품을 모두 버리시겠습니까?";
|
||
|
|
||
|
countSelectUi.SetActive(false);
|
||
|
gameObject.SetActive(true);
|
||
|
}
|
||
|
|
||
|
public void CountDownButton()
|
||
|
{
|
||
|
currentCount--;
|
||
|
currentCount = Mathf.Clamp(currentCount, 1, selectedList[0].ItemSlot.Count);
|
||
|
countText.text = currentCount.ToString();
|
||
|
}
|
||
|
|
||
|
public void CountUpButton()
|
||
|
{
|
||
|
currentCount++;
|
||
|
currentCount = Mathf.Clamp(currentCount , 1, selectedList[0].ItemSlot.Count);
|
||
|
countText.text = currentCount.ToString();
|
||
|
}
|
||
|
|
||
|
public void DiscardButton()
|
||
|
{
|
||
|
if (removeType == RemoveType.SINGLE)
|
||
|
{
|
||
|
DataManager.Inst.CurrentInventory.RemoveItem(selectedList[0].ItemSlot, currentCount);
|
||
|
}
|
||
|
else if (removeType == RemoveType.MULTI)
|
||
|
{
|
||
|
foreach (var element in selectedList)
|
||
|
{
|
||
|
DataManager.Inst.CurrentInventory.RemoveItem(element.ItemSlot, element.ItemSlot.Count);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
CancelButton();
|
||
|
}
|
||
|
|
||
|
public void CancelButton()
|
||
|
{
|
||
|
removeType = RemoveType.NONE;
|
||
|
selectedList.Clear();
|
||
|
countSelectUi.SetActive(false);
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
}
|
||
|
}
|