private void GetAdjacentCellsWithPieceRecursively(CellController cellController, ref List <CellController> matchedCells, int pieceCount, bool allowBetterMatches)
        {
            var row = cellController.Row;
            var col = cellController.Col;

            foreach (var indexHelper in _adjacentIndexHelper)
            {
                var adjacentCell = _model.Cells[row + (int)indexHelper.x, col + (int)indexHelper.y];
                if (adjacentCell != null && adjacentCell.HasPiece() && !matchedCells.Contains(adjacentCell))
                {
                    matchedCells.Add(adjacentCell);

                    if (!allowBetterMatches && matchedCells.Count == pieceCount)
                    {
                        return;
                    }

                    GetAdjacentCellsWithPieceRecursively(adjacentCell, ref matchedCells, pieceCount, allowBetterMatches);
                }
            }
        }
Beispiel #2
0
        public CellController CreateController(Cell model, CellView view)
        {
            var controller = new CellController(model, view);

            return(controller);
        }