miepzerino
2023-12-16 b1ad1febe26938a97bb414620c49b580caf58336
Assets/Scripts/Damageable.cs
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -32,8 +33,6 @@
        {
            if (value > MaxHealth)
            {
                Debug.Log("Warum?");
                _health = MaxHealth;
            }
            else
@@ -85,8 +84,27 @@
    {
        if (IsAlive && !isInvincible)
        {
            Health -= damage;
            int actualDamageAmount = Mathf.Min(damage, Health);
            Health -= actualDamageAmount;
            isInvincible = true;
            CharacterEvents.characterDamaged.Invoke(gameObject, actualDamageAmount);
        }
    }
    public bool Heal(int healAmount)
    {
        bool result = false;
        if (IsAlive && Health < MaxHealth)
        {
            int actualHealAmount = Mathf.Min(healAmount, MaxHealth - Health);
            Health += actualHealAmount;
            CharacterEvents.characterHealed.Invoke(gameObject, actualHealAmount);
            result = true;
        }
        return result;
    }
}