Time for action – scores and scoring chains
Add a method to the
Game1
class to calculate a score based on the number of pipes used:Private Function DetermineScore(squareCount As Integer) As Integer Return CInt( ((Math.Pow((squareCount / 5), 2) + squareCount) * 10)) End Function
Add a method to evaluate a chain to determine if it scores and process it:
Private Sub CheckScoringChain(WaterChain As List(Of Vector2)) If (WaterChain.Count > 0) Then Dim LastPipe As Vector2 = WaterChain(WaterChain.Count - 1) If LastPipe.X = gameBoard.GameBoardWidth Then If _gameBoard.HasConnector( CInt(LastPipe.X), CInt(LastPipe.Y), "Right") Then playerScore += DetermineScore(WaterChain.Count) For Each thisPipe As Vector2 In WaterChain _gameBoard.SetSquare( CInt(thisPipe.X), CInt(thisPipe.Y), "Empty") Next End If End If End If End Sub
What just happened?
DetermineScore()
accepts the number...