Exemplo n.º 1
0
    public virtual void TakeDamage(float damageTaken)
    {
        healthPoints -= damageTaken;

        if (healthPoints <= 0)
        {
            if (explosionPrefab != null)
            {
                var explosion = Instantiate(explosionPrefab, transform.position, transform.rotation);
                Destroy(explosion, explosionDuration);
            }

            if (dieSound)
            {
                AudioSource.PlayClipAtPoint(dieSound, Camera.main.transform.position, dieSoundVolume);
            }

            if (points > 0 && gameSession)
            {
                gameSession.AddPointsToScore(points);
            }

            HandleDeath();

            Destroy(gameObject);
        }
        else
        {
            if (hitSound)
            {
                AudioSource.PlayClipAtPoint(hitSound, Camera.main.transform.position, hitSoundVolume);
            }
        }
    }
Exemplo n.º 2
0
 public void DestroyBlockAsync()
 {
     TriggerVisualEffect();
     PlayBlockDestroySound();
     level.RemoveBreakableObject();
     gameStatus.AddPointsToScore(scoreForBreak);
     Destroy(gameObject);
 }