Files
LowPolyFPS/Assets/Scripts/HealthPickup.cs
2026-10-12 21:28:47 +01:00

31 lines
817 B
C#

using UnityEngine;
public class HealthPickup : PickupItem
{
[Header("Health Settings")]
[SerializeField] private int healAmount = 25;
[SerializeField] private bool onlyCollectWhenDamaged = true;
protected override bool CanCollect(GameObject player)
{
if (PlayerHealthController.Instance == null) return false;
if (PlayerHealthController.Instance.IsDead) return false;
if (onlyCollectWhenDamaged)
{
return PlayerHealthController.Instance.CurrentHealth < PlayerHealthController.Instance.MaxHealth;
}
return true;
}
protected override void ApplyPickupEffect(GameObject player)
{
if (PlayerHealthController.Instance != null)
{
PlayerHealthController.Instance.Heal(healAmount);
}
}
}