diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/PlayerDataManager.cs b/Gameton-06/Assets/Gameton/Scripts/Character/PlayerDataManager.cs index 5ce1ed88..2216ed4e 100644 --- a/Gameton-06/Assets/Gameton/Scripts/Character/PlayerDataManager.cs +++ b/Gameton-06/Assets/Gameton/Scripts/Character/PlayerDataManager.cs @@ -88,6 +88,21 @@ namespace TON } } + public void AddPotion(string type, int amount) + { + switch (type) + { + case "HP": + userItem.hpPotion += amount; + itemDataManager.UpdateHpData(userItem.hpPotion); + break; + case "MP": + userItem.mpPotion += amount; + itemDataManager.UpdateMpData(userItem.mpPotion); + break; + } + } + public void AddGold(int amount) { goldAmount += amount; diff --git a/Gameton-06/Assets/Gameton/Scripts/UI/ShopUI.cs b/Gameton-06/Assets/Gameton/Scripts/UI/ShopUI.cs index 6e00c5f8..0d8a33ca 100644 --- a/Gameton-06/Assets/Gameton/Scripts/UI/ShopUI.cs +++ b/Gameton-06/Assets/Gameton/Scripts/UI/ShopUI.cs @@ -6,16 +6,16 @@ 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 접근 @@ -26,12 +26,12 @@ namespace TON Debug.LogError("PlayerDataManager가 초기화되지 않았습니다."); } } - + public void OnClickLobbyButton() { Main.Singleton.ChangeScene(SceneType.Lobby); } - + // 포션 구매 메서드 private void BuyPotion(int price, string potionType, int quantity) { @@ -43,19 +43,19 @@ namespace TON { if (potionType == "hp") { - playerDataManager.userItem.hpPotion += quantity; + playerDataManager.AddPotion("HP", quantity); } else if (potionType == "mp") { - playerDataManager.userItem.mpPotion += quantity; + playerDataManager.AddPotion("MP", quantity); } - + UIManager.Singleton.UpdateCashData(); } }); } } - + // HP 포션 구매 버튼 클릭 시 호출 public void OnClickBuyHpPotion1Button() {