using UnityEngine;

public class DimensionController : MonoBehaviour
{
    public const int STARTING_HP = 25;

    [SerializeField] private int dimensionId;
    private float _hp;
    private float _maxHp;
    private void Start()
    {
        _maxHp = STARTING_HP;
        _hp = _maxHp;
    }

    private void OnTriggerEnter(Collider other)
    {
        if (_hp <= 0) { return; }

        var enemy = other.GetComponent<Enemy>();
        if (ReferenceEquals(enemy, null)) return;
        
        // Update HP (temp for now)
        _hp -= enemy.DamageDealt();
        
        // Destroy projectile
        Destroy(other.gameObject);

        GameManager.Instance.DealDamage(dimensionId, _hp, _maxHp);
    }

}
