public static List<FlingMove> SearchMoves(CellCollection cells) { List<FlingMove> _result = new List<FlingMove>(); foreach (Cell item in cells) { if (!item.IsEmpty) { foreach (Directions dir in DirectionManager.AllDirections) { if (DirectionManager.IsCrosswise(dir)) continue; Cell _startBall = item; Cell _hitBall = item; FlingMove _parentMove = null; FlingMove _activeMove = null; int _moveCount = 0; while (cells.RoverCell(ref _hitBall, dir)) { _moveCount++; if (!_hitBall.IsEmpty) { if (_parentMove != null || _moveCount > 1) { FlingMove _move = new FlingMove() { StartBall = _startBall, Dir = dir, MoveCount = _moveCount, HitBall = _hitBall, }; if (_parentMove == null) { _parentMove = _activeMove = _move; _result.Add(_parentMove); } else { _activeMove.RelatedMove = _activeMove = _move; } _moveCount = 0; _startBall = _hitBall; } else break; } } } } } return _result; }
public bool Contains(CellCollection cells, Cell cell) { Cell _rover = this.StartBall; while (_rover != this.HitBall) { if (_rover == cell) return true; cells.RoverCell(ref _rover, this.Dir); } return false; }