Esempio n. 1
0
    public void TakeDamage(int damage)
    {
        //Debug.LogFormat("{0} take {1} damage", gameObject.name, damage.ToString());

        stats.TakeDamage(damage);

        //Add visualization of damage
        if (audioController != null)
        {
            audioController.PlayClip(stats.shipDefinition.hitSoundFX, 0.9f, 1.1f);
        }

        if (stats.GetHealth() <= 0)
        {
            //Debug.LogFormat("{0} health less then 0", gameObject.name);

            StopAllCoroutines();

            var destructibles = GetComponents(typeof(IDestructable));
            foreach (IDestructable d in destructibles)
            {
                d.OnDestruction(transform.position);
            }
        }
    }