Projext/Assets/Scripts/Items/Pickups/HealthPotion.cs

20 lines
1.4 KiB
C#
Raw Normal View History

2026-02-12 15:23:25 +00:00
using UnityEngine; // 유니티 기본 기능을 쓰기 위해 불러올거에요 -> UnityEngine를
2026-02-12 15:23:25 +00:00
public class HealthPotion : MonoBehaviour // 클래스를 선언할거에요 -> 체력 포션 아이템인 HealthPotion을
{ // 코드 블록을 시작할거에요 -> HealthPotion 범위를
2026-02-12 15:23:25 +00:00
[Header("--- 포션 설정 ---")] // 인스펙터에 제목을 표시할거에요 -> --- 포션 설정 --- 을
[SerializeField] private float healAmount = 30f; // 변수를 선언할거에요 -> 회복량(30)을 healAmount에
2026-02-12 15:23:25 +00:00
// PlayerInteraction에서 호출할 함수 // 설명을 적을거에요 -> 상호작용 스크립트가 이걸 실행한다는 걸
public void Use(PlayerHealth target) // 함수를 선언할거에요 -> 대상 플레이어를 회복시키는 Use를
{ // 코드 블록을 시작할거에요 -> Use 범위를
if (target == null) return; // 조건이 맞으면 종료할거에요 -> 대상이 없으면 아무것도 안 함
2026-02-12 15:23:25 +00:00
target.Heal(healAmount); // 함수를 실행할거에요 -> 플레이어 체력을 healAmount 만큼 회복
Debug.Log($"<color=green>[Potion]</color> 체력 {healAmount} 회복!"); // 로그를 찍을거에요 -> 회복 로그 출력
Destroy(gameObject); // 오브젝트를 삭제할거에요 -> 사용한 포션 아이템 제거
} // 코드 블록을 끝낼거에요 -> Use를
} // 코드 블록을 끝낼거에요 -> HealthPotion을