Time for action – tracking the flood
Add the following declarations to the Game1 class:
const float MaxFloodCounter = 100.0f; float floodCount = 0.0f; float timeSinceLastFloodIncrease = 0.0f; float timeBetweenFloodIncreases = 1.0f; float floodIncreaseAmount = 0.5f;
In the
Update()
method ofGame1.cs
, add the following code to keep track of the increasing flood waters right after thetimeSinceLastInput
variable is updated in theGameState.Playing
case section:timeSinceLastFloodIncrease += (float)gameTime.ElapsedGameTime.TotalSeconds; if (timeSinceLastFloodIncrease >= timeBetweenFloodIncreases) { floodCount += floodIncreaseAmount; timeSinceLastFloodIncrease = 0.0f; if (floodCount >= MaxFloodCounter) { gameOverTimer = 8.0f; gameState = GameStates.GameOver; } }
Update the
CheckScoringChain()
method of the Game1 class by adding the following to decrease the flood counter when the player scores. Place this code right afterplayerScore += DetermineScore...