using UnityEngine;

public class HealthManager : MonoBehaviour {
    public void UpdateHealth(ICharacter character, int amount) {
        character.AdjustHealth(amount);
    }
}

public interface ICharacter {
    int Health { get; set; }
    bool IsAlive { get; set; }
    void AdjustHealth(int amount);
}

public class Character : MonoBehaviour, ICharacter {
    public int health;
    public bool isAlive = true;

    public int Health { get => health; set => health = value; }
    public bool IsAlive { get => isAlive; set => isAlive = value; }

    public void AdjustHealth(int amount) {
        Health += amount;
        if (Health <= 0) {
            Health = 0;
            IsAlive = false;
            OnDeath();
        }
    }

    protected virtual void OnDeath() {
        Debug.Log(name + " is dead");
    }
}

public class Player : Character {
    protected override void OnDeath() {
        base.OnDeath();
        Debug.Log("Player-specific death logic");
    }
}

public class Enemy : Character {
    protected override void OnDeath() {
        base.OnDeath();
        Debug.Log("Enemy-specific death logic");
    }
}
