Example #1
0
    void Die()
    {
        GameObject particleColor = Instantiate(particleEmission, gameObject.transform.position, Quaternion.identity) as GameObject;

        particleColor.GetComponent <ParticleSystem>().startColor = gameObject.GetComponent <SpriteRenderer>().color;

        if (destroySound)
        {
            AudioSource.PlayClipAtPoint(destroySound, Camera.main.transform.position, Mathf.Clamp(sfxVolume + 0.45f, 0.0f, 1.0f));
        }

        if (addScoreParticleEmitter)
        {
            Instantiate(addScoreParticleEmitter);
        }

        scoreRecorder.Score(scoreWeight);
        Destroy(this.gameObject);
    }