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 int DetermineScore(int SquareCount) { return (int)((Math.Pow((SquareCount/5), 2) + SquareCount)*10); }
Add a method to evaluate a chain to determine if it scores and process it:
private void CheckScoringChain(List<Vector2> WaterChain) { if (WaterChain.Count > 0) { Vector2 LastPipe = WaterChain[WaterChain.Count - 1]; if (LastPipe.X == GameBoard.GameBoardWidth - 1) { if (gameBoard.HasConnector( (int)LastPipe.X, (int)LastPipe.Y, "Right")) { playerScore += DetermineScore(WaterChain.Count); foreach (Vector2 ScoringSquare in WaterChain) { gameBoard.SetSquare((int)ScoringSquare.X, (int)ScoringSquare.Y, "Empty"); } } } } }
What just happened?
DetermineScore...