コード例 #1
0
        public void DealDamage(DamageData damageData)
        {
            //Subtract the damage being dealt from our health.
            Health -= damageData.rawDamage;

            //Make sure that our health stays in the range of 0 to max health.
            Health = Mathf.Clamp(Health, 0, GetStatValue(StatTypes.MaxHealth));

            //Alert any listeners that we have died.
            if (Health == 0)
            {
                OnDied.Invoke();
            }

            //Alert any listeners that our health has been changed.
            OnHealthChanged.Invoke();
        }
コード例 #2
0
 public void DealDamage(DamageData damageData) => statsHolder.DealDamage(damageData);