hunterDRuebsamen_Hack-N-Slash/Assets/Scripts/LootScripts/LootBase.cs
using System;
using UnityEngine;

public class LootBase : MonoBehaviour
{
    [SerializeField, Tooltip("how much health or points to apply")] int value;

    [SerializeField] public float spawnRate = 0.10f;

    private GameObject playerGO;
    private Score score;

    public static event Action<LootType, int> onLootPickup;

    public enum LootType
    {
        Coin,
        Potion,
        Weapon
    };

    [SerializeField] LootType type;

    void OnTriggerEnter2D(Collider2D other)
    { //coin is counted in counter and is then destroyed
        print("Collided with: " + other);
        if(other.tag == "Player")
        { 
            onLootPickup?.Invoke(type, value);
            Debug.Log("loot pickup");
            Destroy(gameObject,0.25f);
        }
    }
}