private void ConsumePowerUp(Collider2D player) { if (healthPowerUpAmount >= 0) { PlayerHealth ph = player.GetComponent <PlayerHealth>(); ph.HealPlayer(healthPowerUpAmount); } if (coinPowerUpAmount >= 0) { PlayerMoney pm = player.GetComponent <PlayerMoney>(); pm.GainCoins(coinPowerUpAmount); } if (manaPowerUpAmount >= 0) { PlayerMana playerMana = player.GetComponent <PlayerMana>(); playerMana.GainMana(manaPowerUpAmount); } Destroy(gameObject); }