using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoneyOnEnemyDeath : MonoBehaviour
{
    private HealthComponent healthComp;

    [SerializeField] private float MoneyDropOnDeath;

    private void OnEnable()
    {
        healthComp = GetComponent<HealthComponent>();
        healthComp.OnHealthZero.AddListener(OnDeath);
    }

    private void OnDisable()
    {
        healthComp.OnHealthZero.RemoveListener(OnDeath);
    }

    void OnDeath()
    {
        GameManager.Instance.Balance.Value += MoneyDropOnDeath;
    }
}