Time for action – adding difficulty levels
Add the following declarations to the Game1 class:
int currentLevel = 0; int linesCompletedThisLevel = 0; const float floodAccelerationPerLevel = 0.5f; Vector2 levelTextPosition = new Vector2(512, 215);
Add the
StartNewLevel()
method to the Game1 class:private void StartNewLevel() { currentLevel++; floodCount = 0.0f; linesCompletedThisLevel = 0; floodIncreaseAmount += floodAccelerationPerLevel; gameBoard.ClearBoard(); gameBoard.GenerateNewPieces(false); }
Modify the
Update()
method of the Game1 class by updating the case section forGameState.TitleScreen
to include the following right before the game state is set toGameState.Playing
:currentLevel = 0; floodIncreaseAmount = 0.0f; StartNewLevel();
Modify the
CheckScoringChain()
method to increment thelinesCompletedThisLevel
variable right afterplayerScore += DetermineScore(WaterChain.Count);
linesCompletedThisLevel++;
Still in the
CheckScoringChain()
method, add the following...