void OnTriggerEnter2D(Collider2D other) { if (isActive) { //If it is a power up, pick it up if (other.CompareTag(TagNames.PowerUp)) { //If we had a power up active, end its effect if (currentPowerUp != null) { currentPowerUp.end(); } currentPowerUp = other.GetComponent <PowerUp>(); currentPowerUp.pickUp(this); } //It can only be hit by an enemy if it is not invulnerable IEnemy enemy = other.GetComponent(typeof(IEnemy)) as IEnemy; if (enemy != null && !isInvulnerable) { GameCamera.instance.shake(0.5f, 0.5f); customParticleEmitter.explosion(color, cachedTransform.position); kill(); } } }