update tùm lum tùm la
This commit is contained in:
28
Assets/Scripts/Interactables/HealthInteractable.cs
Normal file
28
Assets/Scripts/Interactables/HealthInteractable.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
public class HealthInteractable : BaseInteractable
|
||||
{
|
||||
[SerializeField] private float healAmount = 25f;
|
||||
[SerializeField] private bool destroyOnInteract = true;
|
||||
|
||||
protected override void PerformInteraction(PlayerStateMachine player)
|
||||
{
|
||||
if (player.TryGetComponent(out Health health))
|
||||
{
|
||||
health.Heal(healAmount);
|
||||
Debug.Log($"[Healing] Restored {healAmount} health.");
|
||||
|
||||
if (destroyOnInteract)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Healing] Player has no Health component!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user