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

@@ -1,19 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TON
{
public class FishPopup : UIBase
{
private void OnEnable()
{
Invoke(nameof(HidePopup), 3f);
}
private void HidePopup()
{
UIManager.Hide<FishPopup>(UIList.FishPopup);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 2e8e4ece5f5d84f43a51d6804fb38019
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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)
{

View File

@@ -53,7 +53,7 @@ namespace TON
{
int minutes = Mathf.FloorToInt(TOP_RECORD.playTime / 60f);
int seconds = Mathf.FloorToInt(TOP_RECORD.playTime % 60f);
playTime.text = $"{minutes:00}m {seconds:00}s";
playTime.text = $"{minutes:0}m {seconds:0}s";
}
}

View File

@@ -10,19 +10,22 @@ namespace TON
{
public static PauseUI Instance => UIManager.Singleton.GetUI<PauseUI>(UIList.PauseUI);
public GameObject rechargeModal;
public GameObject retryModal;
public GameObject homeModal;
[SerializeField] private GameObject rechargeModal;
[SerializeField] private GameObject retryModal;
[SerializeField] private GameObject homeModal;
[SerializeField] private GameObject fishPopup;
[SerializeField] private TextMeshProUGUI fishAmount;
private Coroutine autoCloseCoroutine; // 팝업 닫기 코루틴 저장
void OnEnable()
{
InitModalActive();
UpdateFishCount();
// 일시정지 시 게임 일시정지
Time.timeScale = 0f;
InitModalActive();
UpdateFishCount();
}
public void InitModalActive()
@@ -30,6 +33,7 @@ namespace TON
rechargeModal.SetActive(false);
retryModal.SetActive(false);
homeModal.SetActive(false);
fishPopup.SetActive(false);
}
public void UpdateFishCount()
@@ -111,9 +115,37 @@ 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)
{