| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | |
| | | { |
| | | if (value > MaxHealth) |
| | | { |
| | | |
| | | Debug.Log("Warum?"); |
| | | _health = MaxHealth; |
| | | } |
| | | else |
| | |
| | | { |
| | | if (IsAlive && !isInvincible) |
| | | { |
| | | Health -= damage; |
| | | int actualDamageAmount = Mathf.Min(damage, Health); |
| | | Health -= actualDamageAmount; |
| | | isInvincible = true; |
| | | |
| | | CharacterEvents.characterDamaged.Invoke(gameObject, damage); |
| | | 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; |
| | | } |
| | | } |