Пример #1
0
 private void ProcessHit(DamageDealer damageDealer)
 {
     playerhealth -= damageDealer.Damage();
     damageDealer.Hit();
     if (playerhealth <= 0)
     {
         Die();
     }
 }
Пример #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DamageDealer damaging = other.GetComponent <DamageDealer>();

        if (damaging)
        {
            health -= damaging.Damage();

            if (health <= 0)
            {
                GameObject newLExplosionVFX = Instantiate(laserExplosionVFX, transform.position, Quaternion.identity);
                newLExplosionVFX.transform.parent = enemySpawner.CleanUpContainer();
                Destroy(newLExplosionVFX, 1f);
                Destroy(this.gameObject);
            }
        }
    }
Пример #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DamageDealer damaging = other.GetComponent <DamageDealer>();

        if (damaging)
        {
            health -= damaging.Damage();

            if (health <= 0)
            {
                gameState.AddScore(score);
                GameObject newVFX = Instantiate(explosionParticleVFX, transform.position, Quaternion.identity);
                newVFX.transform.parent = enemySpawner.CleanUpContainer();
                Destroy(newVFX, 1f);
                AudioSource.PlayClipAtPoint(enemyDeathAudioClip, Camera.main.transform.position, 0.5f);
                Destroy(this.gameObject);
            }
        }
    }
Пример #4
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DamageDealer damaging = other.GetComponent <DamageDealer>();

        if (damaging)
        {
            health -= damaging.Damage();
            if (health < 0)
            {
                health = 0;
            }
            text.text = health.ToString();

            if (health <= 0)
            {
                AudioSource.PlayClipAtPoint(playerDeathAudioClip, Camera.main.transform.position);
                level.LoadGameOver();
                Destroy(this.gameObject);
            }
        }
    }