2024-06-09 18:19:32 +00:00
|
|
|
using System;
|
2024-06-03 18:26:03 +00:00
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using DG.Tweening;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
|
|
namespace BlueWater.Uis
|
|
|
|
{
|
|
|
|
public class ItemLootInfoUi : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField]
|
|
|
|
private Image _itemImage;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private TMP_Text _itemNameText;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private TMP_Text _totalItemCountText;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private float _moveDuration = 0.5f;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private float _showDuration = 2f;
|
|
|
|
|
2024-06-29 15:59:31 +00:00
|
|
|
public bool IsShowing { get; private set; }
|
|
|
|
|
|
|
|
private Tween _showTween;
|
|
|
|
private Tween _hideTween;
|
2024-06-03 18:26:03 +00:00
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
2024-06-29 15:59:31 +00:00
|
|
|
_hideTween = transform.DOScale(0f, _moveDuration).From(Vector3.one).Pause()
|
|
|
|
.SetAutoKill(false).OnComplete(() =>
|
|
|
|
{
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
IsShowing = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
_showTween = transform.DOScale(1f, _moveDuration).From(Vector3.zero).Pause()
|
|
|
|
.SetAutoKill(false).OnComplete(() =>
|
|
|
|
{
|
|
|
|
Invoke(nameof(HideUi), _showDuration);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
transform.localScale = Vector3.zero;
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
_showTween.Kill();
|
|
|
|
_hideTween.Kill();
|
2024-06-03 18:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Button("컴포넌트 초기화")]
|
|
|
|
private void InitializeComponents()
|
|
|
|
{
|
|
|
|
_itemImage = transform.Find("Image").GetComponent<Image>();
|
|
|
|
_itemNameText = transform.Find("NameText").GetComponent<TMP_Text>();
|
|
|
|
_totalItemCountText = transform.Find("TotalCountText").GetComponent<TMP_Text>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetInfo(Sprite sprite, string itemNameText, string totalItemCountText)
|
|
|
|
{
|
|
|
|
_itemImage.sprite = sprite;
|
|
|
|
_itemNameText.text = itemNameText;
|
|
|
|
_totalItemCountText.text = totalItemCountText;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ShowUi()
|
|
|
|
{
|
2024-06-29 15:59:31 +00:00
|
|
|
IsShowing = true;
|
2024-06-03 18:26:03 +00:00
|
|
|
transform.SetAsLastSibling();
|
|
|
|
gameObject.SetActive(true);
|
2024-06-29 15:59:31 +00:00
|
|
|
_showTween.Restart();
|
2024-06-03 18:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void HideUi()
|
|
|
|
{
|
2024-06-29 15:59:31 +00:00
|
|
|
_hideTween.Restart();
|
2024-06-03 18:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|