feat: 생선 부족시 사용 경고 알림 팝업 출력

This commit is contained in:
aube.lee
2025-02-28 15:32:48 +09:00
parent 6f69f9a9d7
commit fb4c214162
9 changed files with 327 additions and 156 deletions

View File

@@ -13,8 +13,9 @@ namespace TON
public readonly string GAME_OVER = "£ GAME OVER £";
public readonly string YOU_WIN = "♧ YOU WIN ♧";
public GameObject rechargeModal;
public GameObject retryModal;
[SerializeField] private GameObject rechargeModal;
[SerializeField] private GameObject retryModal;
[SerializeField] private GameObject fishPopup;
[SerializeField] private TextMeshProUGUI title;
[SerializeField] private TextMeshProUGUI goldReward;
@@ -25,6 +26,9 @@ namespace TON
[SerializeField] private GameObject levelUpText;
[SerializeField] private TextMeshProUGUI fishAmount;
private Coroutine autoCloseCoroutine; // 팝업 닫기 코루틴 저장
private int goldAmount = 0; // 광고 보상 수령 후 초기화
private void OnEnable()
@@ -37,7 +41,6 @@ namespace TON
SetUITextMesh();
UpdateFishCount();
// 해당 UI 노출과 함께 게임 클리어 정보 저장
StageManager.Singleton.StageClear();
@@ -52,6 +55,7 @@ namespace TON
levelUpText.SetActive(false);
rechargeModal.SetActive(false);
retryModal.SetActive(false);
fishPopup.SetActive(false);
}
public void SetUITextMesh()
@@ -145,9 +149,36 @@ namespace TON
{
// 생선 재화 사용 불가 팝업
Debug.Log("생선 재화 사용 불가 팝업");
ShowTimedPopup();
}
});
}
// UI 버튼에 연결할 메서드
public void ShowTimedPopup()
{
// 이미 실행 중인 코루틴이 있다면 중지
if (autoCloseCoroutine != null)
{
StopCoroutine(autoCloseCoroutine);
}
// UI 표시
fishPopup.SetActive(true);
// 자동 닫기 코루틴 시작
autoCloseCoroutine = StartCoroutine(AutoClosePopup());
}
private IEnumerator AutoClosePopup()
{
// Time.timeScale의 영향을 받지 않는 대기
yield return new WaitForSecondsRealtime(3f);
// 시간이 지나면 UI 닫기
fishPopup.SetActive(false);
autoCloseCoroutine = null;
}
private static void AddHeart(int count)
{