CapersProject/Assets/02.Scripts/Ui/Combat/DiscardPopupUi.cs
Nam Tae Gun 7fb0da5888 #25, #26 아이템 직접 획득 방식 추가 및 선형적인 맵 구조 변경
+ Item관련 Excel, Json, So 수정
+ DropItemTable 로직 수정
+ 아이템 프리팹에서 Enable Interaction 체크하면 직접 룻팅, 해제하면 자동 룻팅
+ 체력회복 아이템 추가
+ 개발자 메뉴 상호작용 "F1" 키를 통해 접근 가능
+ 보스 맵은 마법진을 상호작용하면 보스전 시작
+ 맵 안에서 교전 중일 때, 투명 벽 쉐이더 추가
+ 맵 마다의 통로를 통해서 이동 가능
+ 선형적인 맵 구조에 맞게 리소스 및 위치 수정
+ 타이틀 화면으로 이동할 때 나타나는 오류 수정(CombatUiManager OnDisable 싱글톤 문제)

Closes #25, #26
2024-06-22 07:11:53 +09:00

102 lines
3.2 KiB
C#

using System.Collections.Generic;
using BlueWater.Items;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
namespace BlueWater.Uis
{
public class DiscardPopupUi : PopupUi
{
private enum RemoveType
{
None = 0,
Single,
Multi
}
[SerializeField, Required]
private TMP_Text _contentText;
[SerializeField, Required]
private GameObject _countSelectUi;
[SerializeField, Required]
private TMP_Text _countText;
private List<ItemSlotUi> _selectedList = new();
private int _currentCount = 1;
private RemoveType _removeType;
[Button("컴포넌트 초기화")]
private void InitializeComponents()
{
_contentText = transform.Find("DiscardPanel/Content/ContentText").GetComponent<TMP_Text>();
_countSelectUi = transform.Find("DiscardPanel/CountSelectUi").gameObject;
_countText = _countSelectUi.transform.Find("CountBackground/CountText").GetComponent<TMP_Text>();
}
public override void Close()
{
_removeType = RemoveType.None;
_selectedList.Clear();
_countSelectUi.SetActive(false);
base.Close();
}
public void DiscardMessage(ItemSlotUi selectedSlot)
{
_removeType = RemoveType.Single;
_selectedList.Clear();
_selectedList.Add(selectedSlot);
_contentText.text = ItemManager.Instance.GetItemDataByIdx(selectedSlot.ItemSlot.Idx).Name + "을(를) 버리시겠습니까?";
_currentCount = 1;
_countText.text = _currentCount.ToString();
_countSelectUi.SetActive(true);
Open(CombatUiManager.Instance.PopupUiList);
}
public void DiscardAllMessage(List<ItemSlotUi> selectedSlotList)
{
_removeType = RemoveType.Multi;
_selectedList = new List<ItemSlotUi>(selectedSlotList);
_contentText.text = "선택한 물품을 모두 버리시겠습니까?";
_countSelectUi.SetActive(false);
Open(CombatUiManager.Instance.PopupUiList);
}
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.Instance.CombatInventory.RemoveItem(_selectedList[0].ItemSlot, _currentCount);
}
else if (_removeType == RemoveType.Multi)
{
foreach (var element in _selectedList)
{
DataManager.Instance.CombatInventory.RemoveItem(element.ItemSlot, element.ItemSlot.Count);
}
}
Close();
}
}
}