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

@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@@ -20,12 +21,24 @@ namespace TON
public ControllerUI_SkillButton skillButtonPrefab;
private List<ControllerUI_SkillButton> createdSkillButtons = new List<ControllerUI_SkillButton>();
public UserItemData userItem { get; private set; } = new UserItemData();
// 보유 포션 수량
[SerializeField] private TextMeshProUGUI hpPotionCount;
[SerializeField] private TextMeshProUGUI mpPotionCount;
public List<ControllerUI_ItemButton> itemButtons = new List<ControllerUI_ItemButton>();
private void OnEnable()
{
skillButtonPrefab.gameObject.SetActive(false);
Initalize();
}
private void FixedUpdate()
{
InitalizeItemData();
}
public void Initalize()
{
// 이미 기존에 UI가 생성되어 있다면 삭제
@@ -59,6 +72,36 @@ namespace TON
}
}
private void InitalizeItemData()
{
userItem = PlayerDataManager.Singleton.userItem;
hpPotionCount.text = $"{userItem.hpPotion}";
mpPotionCount.text = $"{userItem.mpPotion}";
}
public void OnClickHpPotionButton()
{
if (userItem.hpPotion <= 0)
return;
PlayerDataManager.Singleton.UsePotion("HP");
itemButtons[0].SetCurrentCoolDown();
linkedCharactor.UsePotion("HP");
}
public void OnClickMpPotionButton()
{
if (userItem.mpPotion <= 0)
return;
PlayerDataManager.Singleton.UsePotion("MP");
itemButtons[1].SetCurrentCoolDown();
linkedCharactor.UsePotion("MP");
}
public void OnClickJumpButton()
{
linkedCharactor.Jump();