Beispiel #1
0
    private void TakeHit(DamageDealer damageDealer)
    {
        health -= damageDealer.GetDamageToDeal();
        damageDealer.Hit();
        flashRed();
        transform.position = new Vector3(transform.position.x, transform.position.y + .25f, transform.position.z);

        if (health <= 0)
        {
            score score = FindObjectOfType <score>();
            score.addToScore(pointValue);
            var sparkles = Instantiate(explosion, transform.position, Quaternion.identity);
            AudioSource.PlayClipAtPoint(explodeSound, transform.position, explodeVolume);
            dropPowerup();
            Destroy(gameObject);
            Destroy(sparkles, 1f);
        }
    }