Ejemplo n.º 1
0
    /// <summary>
    /// Damages the current character.
    /// </summary>
    /// <param name="attacker"></param>
    /// <param name="amount"></param>
    public void Damage(GameObject attacker, IDamageSource damageSource, int amount)
    {
        // No hurting yourself!!!
        if (attacker == gameObject)
        {
            return;
        }
        // Hitting the deceased is not very nice at all.
        if (!character.healthProperties.alive)
        {
            return;
        }

        amount = ApplyDamageMultipliers(attacker, amount);

        character.healthProperties.health -= amount;

        if (character.healthProperties.health <= 0)
        {
            character.healthProperties.health = 0;
            Kill();
        }

        characterAnimator.HitFlash();

        if (gameObject.tag != "Player")
        {
            characterMovement.Knockback(
                attacker.transform.position,
                ApplyDamageMultipliers(attacker, 3000)
                );
            characterAnimator.CancelAnimation();
        }

        audioSource.PlayOneShot(damageSource.GetHitSound(), 10f + 1 * attacker.GetComponent <Character>().evolutionProperties.CurrentEvolution.CalculateStatMul());
    }