Exemple #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        var laser = collider.gameObject.GetComponent <Projectile>();

        if (laser != null)
        {
            if (this.ImpactSound != null)
            {
                AudioClipHelper.PlayClipAt(this.ImpactSound, this.transform.position, this.ImpactSoundVolume);
            }
            laser.Hit();
            this.Health -= laser.GetDamage();
            if (this.Health <= 0)
            {
                var music = FindObjectOfType <Music>();
                if (music != null)
                {
                    music.Stop();
                }
                foreach (var system in FindObjectsOfType <ParticleSystem>())
                {
                    if (system.startSpeed > 1)
                    {
                        system.Stop();
                        system.Clear();
                    }
                }
                FindObjectOfType <EnemySpawner>().Stop();
                this.Invoke("Destroy", this.KillDelay);
            }
        }
    }
Exemple #2
0
    void OnTriggerEnter2D(Collider2D collider2D)
    {
        var laser = collider2D.gameObject.GetComponent <Projectile>();

        if (laser)
        {
            if (this.ImpactSound != null)
            {
                AudioClipHelper.PlayClipAt(this.ImpactSound, this.transform.position, this.ImpactSoundVolume);
            }
            laser.Hit();
            this.Health -= laser.GetDamage();
            if (this.Health <= 0)
            {
                var scoreKeeper = FindObjectOfType <ScoreKeeper>();
                if (scoreKeeper != null)
                {
                    scoreKeeper.IncrementScore(this.KillPoints);
                }
                if (this.KillSound != null)
                {
                    AudioClipHelper.PlayClipAt(this.KillSound, this.transform.position, this.KillSoundVolume);
                }
                Destroy(this.gameObject);
            }
        }
    }
Exemple #3
0
    void Destroy()
    {
        if (this.KillSound != null)
        {
            AudioClipHelper.PlayClipAt(this.KillSound, this.transform.position, this.KillSoundVolume);
        }
        var levelManager = FindObjectOfType <LevelManager>();

        levelManager.LoadLevel("Game Over", this.GameOverDelay);
        Destroy(this.gameObject);
    }