public void TriggerPowerup(GameObject powerup) { _soundManager.PlayPowerupSound(); switch (powerup.GetComponent <PowerupScript>().PowerupTag) { case "Ball split": break; case "Extra paddle": _paddleManager.CreateNewPaddle(); break; case "Power ball": _brickManager.SetPowerModeEnabled(true); break; case "Slow ball": _gameManager.DecreaseBallSpeed(); break; case "Laser gun": break; case "Wide paddle": _paddleManager.WidenPaddles(); break; case "Shockwave": _brickManager.StartShockwave(); break; case "Shield": break; } ResetPowerup(powerup); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { StopGame(); } if (!IsStarted) { StartGame(); } #region Editor stuff #if UNITY_EDITOR if (Input.GetKeyUp(KeyCode.Return)) { AddScore(100000); } if (Input.GetKeyUp(KeyCode.Escape) && !IsPaused) { TogglePause(); } if (Input.GetKeyUp(KeyCode.Tab)) { //var ring = _brickRings[0]; //foreach (Transform brick in ring.Anchor.transform) // brick.gameObject.SetActive(false); //CheckRings(); _paddleManager.WidenPaddles(); } #endif #endregion //if (SystemInfo.deviceType == DeviceType.Handheld) //{ // // Invert the z and w of the gyro attitude // var rotation = Input.gyro.attitude; // Physics.gravity = rotation * new Vector3(0, 1, 0); //} switch (_currentState) { case -1: // Switch to lost screen StopGame(); break; case 1: // Switch to won screen StopGame(); break; } if (IsPaused) { return; } // Update score if (_actualPointScore != _textPointScore) { _textPointScore += Mathf.CeilToInt((_actualPointScore - _textPointScore) / 2f); _scoreText.text = GameVariablesScript.ConvertScoreToString(_textPointScore); Debug("Hi"); } // Update time if (TimerStarted) { #region Timer Text _timer += Time.smoothDeltaTime; var minutes = Mathf.Floor(_timer / 60); var seconds = (_timer % 60); _timeText.text = minutes.ToString("00") + ":" + seconds.ToString("00"); #endregion #region Ball Speed Increase // Update the timer that increases ball speed _speedIncreaseTimer += Time.smoothDeltaTime; if (!_eventCreated && _speedIncreaseTimer > TimeForSpeedIncrease - TimeForSpeedIncreaseEvent) { _eventManager.CreateEvent("+", TimeForSpeedIncreaseEvent, 1); _eventCreated = true; } else if (_speedIncreaseTimer >= TimeForSpeedIncrease) { IncreaseBallSpeed(); _speedIncreaseTimer = 0; _eventCreated = false; } #endregion } #region Camera Shake if (_isCameraShaking) { UpdateShake(); } #endregion #region Combo if (_comboText.enabled) { _comboTimer += Time.smoothDeltaTime; _comboText.transform.localScale = Vector3.Lerp(ComboTextInitialScale, ComboTextFinalScale, _comboTimer / TimeForComboTextShow * 2); if (_comboText.transform.localScale.x > 1) { _comboText.transform.localScale = new Vector3(1, 1, 1); } if (_comboTimer > TimeForComboTextShow) { _comboTimer = 0; _comboText.enabled = false; } } #endregion #region Background Colour Shift var colour = _backgroundImage.color; switch (_backgroundColourIndex) { case 0: colour.r += BackgroundColourChangeSpeed / 255f; if (colour.r >= 1) { _backgroundColourIndex++; } break; case 1: colour.b -= BackgroundColourChangeSpeed / 255f; if (colour.b <= 0) { _backgroundColourIndex++; } break; case 2: colour.g += BackgroundColourChangeSpeed / 255f; if (colour.g >= 1) { _backgroundColourIndex++; } break; case 3: colour.r -= BackgroundColourChangeSpeed / 255f; if (colour.r <= 0) { _backgroundColourIndex++; } break; case 4: colour.b += BackgroundColourChangeSpeed / 255f; if (colour.b >= 1) { _backgroundColourIndex++; } break; case 5: colour.g -= BackgroundColourChangeSpeed / 255f; if (colour.g <= 0) { _backgroundColourIndex = 0; } break; } _backgroundImage.color = colour; #endregion }