public void Activate() { if (!activated) { activated = OnActivate(); if (activated) { style.SetPowerUpSprite(null); } } }
void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Power Up")) { if (powerUp != null) { powerUp.OnDeactivate(); } powerUp = generator.GetPowerUp(gameObject); style.SetPowerUpSprite(powerUp.sprite); } else if (other.gameObject.GetComponent <SinglePowerUpGenerator>() != null) { SinglePowerUpGenerator gen = other.gameObject.GetComponent <SinglePowerUpGenerator>(); if (powerUp != null) { powerUp.OnDeactivate(); } powerUp = gen.GetPowerUp(gameObject); Destroy(other.gameObject); } }