Beispiel #1
0
    /// <summary>
    /// Damage this Unit for N ammounts of damage, reduced by Defence.
    /// </summary>
    /// <param name="n">N.</param>
    public int Damage(DamageData attackData)
    {
        // Run attack through defencive buffs and abiliites
        DefenceModifiers(attackData);

        int n = attackData.ApplyDefences(Character.ModifiedStats.defense, Character.ModifiedStats.resistance);

        if (attackData.testAttack)
        {
            return(n);
        }

        AddDamageData(attackData);
        damageTaken += n;
        NotifyHealthObservers(-n);
        if (damageTaken >= Character.ModifiedStats.maxHP)
        {
            attackData.killingBlow = true;
        }

        attackData.Callback();
        if (attackData.crit)
        {
            Particle.Crit(transform.position);
        }

        if (attackData.killingBlow)
        {
            Death(false);
            SFXPlayer.Instance.DeathSound();
        }

        return(n);
    }
Beispiel #2
0
    public void DefenceTest(DamageData dd)
    {
        Stats s = dd.target.GetStatsAt(dd.target.Tile);

        if (dd.ApplyDefences(s.defense, s.resistance) >= dd.target.CurrentHP)
        {
            dd.damageMultipler *= 0.5f;
        }
    }