Ejemplo n.º 1
0
    public void ApplyDamage(float dmg, Ship attacker)
    {
        if (attacker != null)
        {
            dmg = dmg * attacker.damageMult;
        }

        if (health > dmg)
        {
            health -= dmg;
        }
        else
        {
            health = 0;

            GlobalEvents.AsteroidDestroyed(this);
            ParticleEffects.current.SpawnAsteroidDebries(transform.position, sprRend);

            if (onDeathSpawnCount > 0)
            {
                for (int i = 0; i < onDeathSpawnCount; i++)
                {
                    Vector3 rnd = Random.insideUnitCircle.normalized;
                    AsteroidSystem.current.SpawnAsteroid(transform.position + rnd, onDeathSpawnSize, false);
                }
            }
        }
    }