Implement health modification on enemy kill; add HealOnKillModifier and update death behavior
This commit is contained in:
@@ -7,16 +7,21 @@ namespace Systems
|
||||
{
|
||||
public class Health : MonoBehaviour
|
||||
{
|
||||
private GameObject lastAttacker;
|
||||
|
||||
[Self, SerializeField] private Character character;
|
||||
[SerializeField] private float initialHealth = 100f;
|
||||
|
||||
public GameObject LastAttacker => lastAttacker;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
character.attributes.SetHealth(initialHealth);
|
||||
}
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
public void TakeDamage(float damage, GameObject attacker = null)
|
||||
{
|
||||
lastAttacker = attacker;
|
||||
var effectiveDamage = Math.Max(damage - character.attributes.Armor, 1);
|
||||
character.attributes.ModifyHealth(-effectiveDamage);
|
||||
}
|
||||
|
Reference in New Issue
Block a user