54 lines
1.6 KiB
C#
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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|