상점 포션 구매 UniRx(MVP 패턴)를 활용하여 수정중

This commit is contained in:
Mingu Kim
2025-06-02 00:28:39 +09:00
parent 8a54d47b56
commit 66ee4d6d2e
6 changed files with 156 additions and 47 deletions

View File

@@ -6,56 +6,12 @@ namespace TON
{
[SerializeField] private GameObject HeartPopUp;
[SerializeField] private GameObject PositionPopUp;
[SerializeField] private int hpPotionPrice1 = 200; // HP 포션 가격
[SerializeField] private int hpPotionPrice5 = 1000; // HP 포션 가격
[SerializeField] private int hpPotionPrice20 = 3600; // HP 포션 가격
[SerializeField] private int mpPotionPrice1 = 400; // MP 포션 가격
[SerializeField] private int mpPotionPrice5 = 2000; // MP 포션 가격
[SerializeField] private int mpPotionPrice20 = 7600; // MP 포션 가격
private PlayerDataManager playerDataManager;
void Start()
{
// 싱글톤으로 PlayerDataManager 접근
playerDataManager = PlayerDataManager.Singleton;
if (playerDataManager == null)
{
Debug.LogError("PlayerDataManager가 초기화되지 않았습니다.");
}
}
public void OnClickLobbyButton()
{
Main.Singleton.ChangeScene(SceneType.Lobby);
}
// 포션 구매 메서드
private void BuyPotion(int price, string potionType, int quantity)
{
if (playerDataManager.goldAmount >= price)
{
playerDataManager.UseGold(price, (isSuccess) =>
{
if (isSuccess)
{
if (potionType == "hp")
{
playerDataManager.AddPotion("HP", quantity);
}
else if (potionType == "mp")
{
playerDataManager.AddPotion("MP", quantity);
}
UIManager.Singleton.UpdateCashData();
}
});
}
}
// HP 포션 구매 버튼 클릭 시 호출
public void OnClickBuyHpPotion1Button()
{