Example #1
0
        public void TryMoveBubble(Cell currentCell)
        {
            _checkLine = new CheckLines(Field, currentCell);
            _checkLine.ScoreChangedEventHandler += OnScoreChange;
            _checkLine.DestroyLinesEventHandler += OnDestroyLines;

            if (currentCell.Contain == null)
            {
                if (MoveBubble(SelectedCell, currentCell))
                {
                    SelectedCell = null;

                    if (!_checkLine.Check())
                    {
                        NextTurn(true);
                    }
                    else
                    {
                        Field.EmptyCells += _checkLine.LineLength;
                        NextTurn(false);
                    }
                }
            }
            else
            {
                if (currentCell.Contain == BubbleSize.Small)
                {
                    Cell CurrentCellDuplicate = new Cell(currentCell);

                    if (MoveBubble(SelectedCell, currentCell))
                    {
                        SelectedCell = null;

                        if (!_checkLine.Check())
                        {
                            Cell newBubble = _bubbleGenerationStrategy.GenerateBubble(Field, BubbleSize.Small, CurrentCellDuplicate.Color);
                            Field.Cells[newBubble.Row, newBubble.Column].Contain = newBubble.Contain;
                            Field.Cells[newBubble.Row, newBubble.Column].Color   = newBubble.Color;
                            NextTurn(true);
                        }
                        else
                        {
                            Field.EmptyCells += _checkLine.LineLength;
                            Field.Cells[currentCell.Row, currentCell.Column] = CurrentCellDuplicate;
                            NextTurn(false);
                        }
                    }
                }
                else
                {
                    SelectBubble(currentCell);
                }
            }
        }
Example #2
0
 private void BubbleRaizing()
 {
     for (int i = 0; i < Field.Height; i++)
     {
         for (int j = 0; j < Field.Width; j++)
         {
             if (Field.Cells[i, j].Contain == BubbleSize.Small)
             {
                 Field.EmptyCells--;
                 Field.Cells[i, j].Contain = BubbleSize.Big;
                 //check if this bubble creates line
                 _checkLine = new CheckLines(Field, Field.Cells[i, j]);
                 _checkLine.ScoreChangedEventHandler += OnScoreChange;
                 _checkLine.DestroyLinesEventHandler += OnDestroyLines;
                 _checkLine.Check();
             }
         }
     }
 }
Example #3
0
        public void TestCheckMethod_RightDiagonalLine()
        {
            Field field = new Field(10, 10);

            field.Cells[5, 1].Contain = BubbleSize.Big;
            field.Cells[5, 1].Color   = BubbleColor.Red;
            field.Cells[4, 2].Contain = BubbleSize.Big;
            field.Cells[4, 2].Color   = BubbleColor.Red;
            field.Cells[3, 3].Contain = BubbleSize.Big;
            field.Cells[3, 3].Color   = BubbleColor.Red;
            field.Cells[2, 4].Contain = BubbleSize.Big;
            field.Cells[2, 4].Color   = BubbleColor.Red;
            field.Cells[1, 5].Contain = BubbleSize.Big;
            field.Cells[1, 5].Color   = BubbleColor.Red;

            CheckLines _checkLines = new CheckLines(field, field.Cells[2, 4]);

            Assert.IsTrue(_checkLines.Check());
        }