IEnumerator powerUpRoutine(Powerup.type type) { handlePowerUpBool(type, 1); yield return(new WaitForSeconds(_powerUpDuration)); handlePowerUpBool(type, -1); }
public void activatePowerUp(Powerup.type type) { Vector3 camera = new Vector3(0, 0, -10); AudioSource.PlayClipAtPoint(powerUpSound, camera); _powerUpTimer = powerUpRoutine(type); StartCoroutine(_powerUpTimer); }
void handlePowerUpBool(Powerup.type type, int instances) { switch (type) { case Powerup.type.triple: _powerUpStatus.tripleShot += instances; break; case Powerup.type.rotate: _powerUpStatus.rotateShot += instances; break; case Powerup.type.homing: _powerUpStatus.homingShot += instances; break; case Powerup.type.glitch: _powerUpStatus.glitchShot += instances; break; case Powerup.type.repair: if (_stats.health < 3 && instances > 0) { _stats.health++; _uIManager.updateLives(_stats.health); restoreEngine(); } break; case Powerup.type.shield: if (instances > 0) { _stats.shield = 3; handleShield(); } break; case Powerup.type.ammo: if (instances > 0) { _stats.ammo = 15; } break; case Powerup.type.breakk: if (_stats.health > 1 && instances > 0) { // Break ignores shields int currentShield = _stats.shield; _stats.shield = 0; Damage(); _stats.shield = currentShield; } break; case Powerup.type.disable: if (_stats.shield > 0 && instances > 0) { // Disable fully removes shield. _stats.shield = 0; handleShield(); } break; case Powerup.type.noammo: if (_stats.ammo > 0 && instances > 0) { // Reduces avaliable ammo by half. _stats.ammo = _stats.ammo / 2; } break; case Powerup.type.star: if (instances > 0) { _uIManager.toggleStar(); if (_gameManager.getMode() == GameManager.mode.wave) { _storyManager.setWave(1); } else { _spawnManager.getItems()[0].setActive(true); } _gameManager.setScoreMult(_gameManager.getScoreMult() + 1); } break; default: break; } updateAmmo(); bool rotateActive = _powerUpStatus.rotateShot > 0; bool homingActive = _powerUpStatus.homingShot > 0; bool glitchActive = _powerUpStatus.glitchShot > 0; rotateAim.SetActive(rotateActive && !(homingActive || glitchActive)); }