feat: 플레이 중 포션 사용 로직 적용

This commit is contained in:
aube.lee
2025-03-01 21:46:27 +09:00
parent 67c017bbbf
commit 068cab2d8a
8 changed files with 576 additions and 25 deletions

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using TMPro;
namespace TON
{
public class ControllerUI_ItemButton : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI coolTimeText;
[SerializeField] private Image coolTimeDimd;
private float currentCoolDown = 0f;
private float potionCoolDown = 5f;
public void SetCurrentCoolDown()
{
currentCoolDown = potionCoolDown; // 쿨타임 시작
}
private void Update()
{
if (currentCoolDown == 0f)
return;
UpdateCooldownUI();
}
private void UpdateCooldownUI()
{
if (coolTimeText == null || coolTimeDimd == null)
{
return; // UI가 삭제되었으면 업데이트 중단
}
currentCoolDown -= Time.deltaTime;
currentCoolDown = Mathf.Max(0, currentCoolDown);
coolTimeText.gameObject.SetActive(currentCoolDown > 0); // 남은 쿨타임이 있을 때만 표시
if (coolTimeText.IsActive())
{
coolTimeText.text = $"{currentCoolDown: 0}s"; // 정수 초단위 표시
coolTimeDimd.fillAmount = currentCoolDown / potionCoolDown; // 1 → 0 으로 감소
}
}
}
}