initial commit
This commit is contained in:
30
Assets/Scripts/HealthPickup.cs
Normal file
30
Assets/Scripts/HealthPickup.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user