OldBlueWater/BlueWater/Assets/02.Scripts/Ui/DiscardPopupUi.cs
NTG 7a2b5e9d02 Closes #255 거대 슬라임 보스 추가
+ UiManager의 CombatUi, OceanUi 모두 분리
각각의 씬에서 CombatUiManager, OceanUiManager로 변경
+ Ocean, OceanUi input action map 추가 및 변경
input action map, uiManager 변경에 따른 Player input 로직 변경
+ CombatPlayer가 죽으면 GameOverUi 추가
+ 재시작 기능 추가
+ 인벤토리 Ui 수정
+ 슬라임 보스 로직 및 애니메이션 수정
2024-05-12 06:29:16 +09:00

89 lines
2.7 KiB
C#

using System.Collections.Generic;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class DiscardPopupUi : PopupUi
{
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 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.Inst.ItemDictionary[selectedSlot.ItemSlot.Idx].name + "을(를) 버리시겠습니까?";
currentCount = 1;
countText.text = currentCount.ToString();
countSelectUi.SetActive(true);
Open();
}
public void DiscardAllMessage(List<ItemSlotUi> selectedSlotList)
{
removeType = RemoveType.MULTI;
selectedList = new List<ItemSlotUi>(selectedSlotList);
contentText.text = "선택한 물품을 모두 버리시겠습니까?";
countSelectUi.SetActive(false);
Open();
}
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);
}
}
Close();
}
}
}