예제 #1
0
        private void CheckScoringChain(List <Vector2> waterChain)
        {
            if (waterChain.Count > 0)
            {
                Vector2 lastPipe = waterChain[waterChain.Count - 1];
                if (lastPipe.X == GameBoard.GameBoardWidth - 1)                                 // Must end on RHS of game board
                {
                    if (_gameBoard.PieceHasConector((int)lastPipe.X, (int)lastPipe.Y, "Right")) // Must be connecting to RHS of board
                    {
                        int score = DetermineScore(waterChain.Count);
                        _playerScore += score;
                        _scoreZooms.Enqueue(new ScoreZoom("+" + score, new Color(1, 0, 0, 0.4f))); // red
                        _currentFloodCount = MathHelper.Clamp(_currentFloodCount - (score / 10), 0, 100);
                        _linesCompletedThisLevel++;


                        // Clear tiles filled with water
                        // will be refilled by calling GenerateNewPieces function
                        foreach (Vector2 tile in waterChain)
                        {
                            _gameBoard.AddFadingPiece((int)tile.X, (int)tile.Y, _gameBoard.GetPieceType((int)tile.X, (int)tile.Y));
                            _gameBoard.SetPieceType((int)tile.X, (int)tile.Y, GamePiece.EmptyPieceType);
                        }

                        if (_linesCompletedThisLevel >= 10)
                        {
                            StartNewLevel();
                        }
                    }
                }
            }
        }