CapersProject/Assets/02.Scripts/Ui/Combat/ItemLootUi.cs
Nam Tae Gun c2f8f02328 버그 및 로직 수정
+ GameManager CurrentCombatPlayer 버그 및 로직 수정
+ 타이탄 슬라임 스프라이트 변경
+ Tycoon action 추가
+ JumpSlam 스프라이트 형식으로 변경
+ Npc 레이어 추가
2024-06-08 02:31:08 +09:00

54 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using BlueWater.Items;
using UnityEngine;
namespace BlueWater.Uis
{
public class ItemLootUi : MonoBehaviour
{
[SerializeField]
private List<ItemLootInfoUi> _itemLootInfoUis = new(3);
private readonly WaitForSeconds _coroutineRestartTime = new(0.5f);
private void Awake()
{
var itemLootInfoUis = GetComponentsInChildren<ItemLootInfoUi>();
foreach (var element in itemLootInfoUis)
{
_itemLootInfoUis.Add(element);
}
foreach (var element in _itemLootInfoUis)
{
element.Initialize();
}
}
public void ShowLootInfoUi(ItemData itemData, int count)
{
StartCoroutine(ShowLootInfoUiCoroutine(itemData, count));
}
private IEnumerator ShowLootInfoUiCoroutine(ItemData itemData, int count)
{
while (true)
{
foreach (var element in _itemLootInfoUis)
{
if (element.gameObject.activeSelf) continue;
var itemNameText = $"+{count} {itemData.Name}";
var totalItemCountText = $"({DataManager.Instance.CombatInventory.GetItemByIdx(itemData.Idx).Count})";
element.SetInfo(itemData.Sprite, itemNameText, totalItemCountText);
element.ShowUi();
yield break;
}
yield return _coroutineRestartTime;
}
}
}
}