private void OnPowerupDeactivated(object data) { APowerup powerup = (APowerup)data; _Powerups.Remove(powerup); Destroy(powerup.gameObject, 3); }
private void OnPowerupActivated(object data) { APowerup powerup = (APowerup)data; // Checking if the powerup is already active and removing the UI PowerupUI[] powerupUIs = _PowerupContainer.GetComponentsInChildren <PowerupUI>(); foreach (var powerupUI in powerupUIs) { if (powerupUI.Powerup.PowerupTag == powerup.PowerupTag) { Destroy(powerupUI.gameObject); } } // Adding the powerup var ui = Instantiate(_PowerupUI, _PowerupContainer.transform); ui.Initialize(powerup); }
private void OnTriggerEnter(Collider collider) { APowerup powerup = collider.GetComponent <APowerup>(); if (powerup != null) { // Resetting a powerup if it has already been picked up for (int i = 0; i < _Powerups.Count; ++i) { if (_Powerups[i].PowerupTag == powerup.PowerupTag) { _Powerups[i].Deactivate(); break; } } // Picking up the power up collider.gameObject.GetComponent <Renderer>().enabled = false; collider.enabled = false; powerup.transform.parent = transform; powerup.Initialize(this); } }
public void Initialize(APowerup powerup) { _PowerupSpriteRenderer.sprite = powerup.PowerupSprite; StartCoroutine(PowerupTimer(powerup.PowerupTime)); }