Example #1
0
    private void HandleDamage(GameObject other)
    {
        DamageDealer dd = other.GetComponent <DamageDealer>();

        if (!dd)
        {
            return;
        }
        if (dd.Simulated == true)
        {
            return;
        }
        if (dd.GetAttackSource())
        {
            ownerOfLastDamageDealerToBeHitBy = dd.GetAttackSource();
        }
        if (dd.GetKnockBackAmount() != 0)
        {
            rb.AddForce(dd.GetKnockBackAmount() * dd.GetComponent <Rigidbody2D>().velocity.normalized, ForceMode2D.Impulse);
        }
        dd.HandleImpactWithTarget(gameObject);

        float incomingDamage = dd.GetDamage();

        if (incomingDamage == 0)
        {
            return;
        }

        ModifyHealth(incomingDamage * -1);
        //Destroy(other);
    }