private void OnTriggerEnter2D(Collider2D other) { DamageDealer damageDealer = other.gameObject.GetComponent <DamageDealer>(); if (other.gameObject.GetComponent <Boost>() != null) { Boost boost = other.gameObject.GetComponent <Boost>(); string boostType = boost.GetEffect(); BoostPlayer(boostType); Destroy(other.gameObject); return; } if (shield) { shield = false; Destroy(shielding); AudioSource.PlayClipAtPoint(boostDown, Camera.main.transform.position, boostDownVolume); } else { health -= damageDealer.GetDamage(); healthBar.SetHealthSlider(health); } if (!damageDealer) { return; } if (other.gameObject.GetComponent <Enemy>() != null) { if (!other.gameObject.GetComponent <Enemy>().IsBoss()) { damageDealer.Hit(); } } else { damageDealer.Hit(); } if (health <= 0) { Die(); } else { if (!shield) { AudioSource.PlayClipAtPoint(damagedVFX, Camera.main.transform.position, damagedSoundVolumee); } } }