Exemplo n.º 1
0
    /**
     * Damage the entity of the given amount
     */
    public void Damage(Focuser source, float amount)
    {
        _healthSystem.Damage(amount);

        if (GetHealth() <= 0f)
        {
            if (source.GetComponent <Entity>())
            {
                source.GetComponent <Entity>().AddKill(1);
            }
            if (this == EntityManager.GetFocusedEntity() && _isLowHealthSoundPlaying)
            {
                SoundManager.StopLowHealthSound(EntityManager.GetFocusedEntity().GetName());
            }

            EntityManager.Remove(this);
            SoundManager.PlayDeadSound(transform.position, .5f);
            Destroy(gameObject);
        }

        // Trigger damage sound
        SoundManager.PlayDamageSound(GetArmor() > 0f, transform.position, .5f);
        StopCoroutine(PlayDamageAnimation());
        StartCoroutine(PlayDamageAnimation());
    }