private void ProcessHit(DamageDealer damageDealer)
    {
        health -= damageDealer.GetDamageAmount();
        damageDealer.Hit();

        if (health <= 0)
        {
            AudioSource.PlayClipAtPoint(explosionSfx, Camera.main.transform.position, explosionVolume);
            Destroy(gameObject);
        }
    }
    private void ProcessHit(DamageDealer damageDealer)
    {
        enemyHealth -= damageDealer.GetDamageAmount();
        damageDealer.Hit();

        if (enemyHealth <= 0)
        {
            GameObject explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity) as GameObject;
            Destroy(gameObject);
            AudioSource.PlayClipAtPoint(explosionSfx, Camera.main.transform.position, explosionVolume);
        }
    }
Esempio n. 3
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.GetComponent <DamageDealer>())
     {
         DamageDealer damageDealer = other.gameObject.GetComponent <DamageDealer>();
         playerHealth -= damageDealer.GetDamageAmount();
         Destroy(other.gameObject);
         if (playerHealth <= 0)
         {
             Destroy(gameObject);
         }
     }
     ;
 }
Esempio n. 4
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.GetComponent <DamageDealer>())
     {
         DamageDealer damageDealer = other.gameObject.GetComponent <DamageDealer>();
         enemyHealth -= damageDealer.GetDamageAmount();
         Destroy(other.gameObject);
         if (enemyHealth <= 0)
         {
             Instantiate(_deathVFX, transform.position, Quaternion.identity);
             Destroy(gameObject);
         }
     }
     ;
 }