コード例 #1
0
ファイル: Character.cs プロジェクト: odmiex/NKM
        private void ReceiveDamage(Damage damage)
        {
            BeforeBeingDamaged?.Invoke(damage);

            var defense = GetDefense(damage.Type);

            damage.Value       -= defense;
            damage.Value        = damage.Value < 0 ? 0 : damage.Value;
            HealthPoints.Value -= damage.Value;

            AfterBeingDamaged?.Invoke(damage);
        }
コード例 #2
0
ファイル: Character.cs プロジェクト: tojatos/NKM
        private void ReceiveDamage(Damage damage)
        {
            BeforeBeingDamaged?.Invoke(damage);

            int   defense   = GetDefense(damage.Type);
            float reduction = damage.Value * defense / 100f;

            damage.Value -= (int)reduction;
            damage.Value  = damage.Value < 0 ? 0 : damage.Value;
            if (Shield.Value >= damage.Value)
            {
                Shield.Value -= damage.Value;
                damage.Value  = 0;
            }
            else
            {
                damage.Value -= Shield.Value;
                Shield.Value  = 0;
            }

            HealthPoints.Value -= damage.Value;

            AfterBeingDamaged?.Invoke(damage);
        }