private void HitHandler() { _scoreManager.AddScore(1); _uiManager.SetScoreUI(_scoreManager.GetScore()); SoundManager.Instance.PlayHitSound(); IncreaseBallDropSpeed(); }
private bool TryToPlaceShape(Shape shape) { // Check if the shape can be placed on the board if (!_gameBoard.IsValidPosition(shape)) { SoundManager.Instance.PlayMissSound(); return(false); } SoundManager.Instance.PlayPlaceSound(); _gameBoard.StoreShapeInGrid(shape); // Score every piece of shape placed on the board and update the score _scoreManager.AddScore(shape.NumberOfContainedPieces()); _uiManager.SetScoreUI(_scoreManager.GetScore()); // Score every cleared row and/or column and update the score _scoreManager.ScoreClearedRowsAndColumns(_gameBoard.ClearAllRowsAndColumns()); _uiManager.SetScoreUI(_scoreManager.GetScore()); // Update the high score if (!_isNewHighScoreMade) { if (_scoreManager.IsNewHighScore()) { SoundManager.Instance.PlayNewHighScoreSound(); _isNewHighScoreMade = true; } } // Remove the placed shape from the available shapes for (int i = 0; i < _shapesInPlay.Length; i++) { if (_shapesInPlay[i] == shape) { _shapesInPlay[i] = null; } } _numberOfShapesInPlay--; // Check if the rest of the shapes can fit and change their color if they cant ChangeColorOfUnfitShape(); if (_numberOfShapesInPlay == 0) { SpawnNewShapes(); } return(true); }