private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.layer == LayerMask.NameToLayer("Enemy1")) { if (mainHallHealth - damageScript.enemy1Damage > 0) { mainHallHealth = mainHallHealth - damageScript.enemy1Damage; Debug.Log("Main Hall health: " + mainHallHealth); soundManager.PlayEfx(3); } else { mainHallHealth = 0; gameOver.GameLost(); Destroy(this.gameObject); } } if (collision.gameObject.layer == LayerMask.NameToLayer("Enemy2")) { if (mainHallHealth - damageScript.enemy2Damage > 0) { mainHallHealth = mainHallHealth - damageScript.enemy2Damage; Debug.Log("Main Hall health: " + mainHallHealth); soundManager.PlayEfx(3); } else { mainHallHealth = 0; gameOver.GameLost(); Destroy(this.gameObject); } } if (collision.gameObject.layer == LayerMask.NameToLayer("Enemy3")) { if (mainHallHealth - damageScript.enemy3Damage > 0) { mainHallHealth = mainHallHealth - damageScript.enemy3Damage; Debug.Log("Main Hall health: " + mainHallHealth); soundManager.PlayEfx(3); } else { mainHallHealth = 0; gameOver.GameLost(); Destroy(this.gameObject); } } }