+ Title Ui 수정 + 전투 맵 이동 위치 수정 + 맵 입구 이미지 변경 + 풀잎 아이템 추가에 따른 Excel, Json, So 수정 + 타이탄 슬라임 맵에서 풀이 잘릴 때, 40% 확률로 풀잎을 드롭 + 타이탄 슬라임 젬스톤 위치 및 재질 변경 + AutoDropItem 프리팹 추가
81 lines
2.6 KiB
C#
81 lines
2.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BlueWater.Items;
|
|
using BlueWater.Utility;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.Uis
|
|
{
|
|
public class ItemLootUi : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private List<ItemLootInfoUi> _itemLootInfoUis = new(3);
|
|
|
|
[ShowInInspector]
|
|
private Queue<(ItemData, int, int)> _waitingLootInfoUis = new();
|
|
|
|
private Coroutine _waitingQueueCoroutineInstance;
|
|
private readonly WaitForSeconds _coroutineRestartTime = new(0.5f);
|
|
|
|
private void Awake()
|
|
{
|
|
var itemLootInfoUis = GetComponentsInChildren<ItemLootInfoUi>();
|
|
foreach (var element in itemLootInfoUis)
|
|
{
|
|
_itemLootInfoUis.Add(element);
|
|
}
|
|
}
|
|
|
|
public void ShowLootInfoUi(ItemData itemData, int count)
|
|
{
|
|
var totalItemCount = DataManager.Instance.CombatInventory.GetItemByIdx(itemData.Idx).Count;
|
|
|
|
if (_waitingLootInfoUis.Count > 0)
|
|
{
|
|
_waitingLootInfoUis.Enqueue((itemData, count, totalItemCount));
|
|
return;
|
|
}
|
|
|
|
foreach (var element in _itemLootInfoUis)
|
|
{
|
|
if (element.IsShowing) continue;
|
|
|
|
SetItemLootInfo(element, itemData, count, totalItemCount);
|
|
return;
|
|
}
|
|
|
|
_waitingLootInfoUis.Enqueue((itemData, count, totalItemCount));
|
|
Utils.StartUniqueCoroutine(this, ref _waitingQueueCoroutineInstance, WaitingQueueCoroutine());
|
|
}
|
|
|
|
private void SetItemLootInfo(ItemLootInfoUi element, ItemData itemData, int count, int totalItemCount)
|
|
{
|
|
var itemNameText = $"+{count} {itemData.Name}";
|
|
var totalItemCountText = $"({totalItemCount})";
|
|
|
|
element.SetInfo(itemData.Sprite, itemNameText, totalItemCountText);
|
|
element.ShowUi();
|
|
}
|
|
|
|
private IEnumerator WaitingQueueCoroutine()
|
|
{
|
|
while (_waitingLootInfoUis.Count > 0)
|
|
{
|
|
foreach (var element in _itemLootInfoUis)
|
|
{
|
|
if (element.IsShowing) continue;
|
|
|
|
var lootInfoUi = _waitingLootInfoUis.Dequeue();
|
|
SetItemLootInfo(element, lootInfoUi.Item1, lootInfoUi.Item2, lootInfoUi.Item3);
|
|
|
|
break;
|
|
}
|
|
|
|
yield return _coroutineRestartTime;
|
|
}
|
|
|
|
_waitingQueueCoroutineInstance = null;
|
|
}
|
|
}
|
|
} |