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 void AddFlingMoveToList(FlingMove move) { ListViewItem _lvi = new ListViewItem(move.StartBall.ToString()); _lvi.SubItems.Add(move.Dir.ToString()); _lvi.SubItems.Add(move.HitBall.ToString()); _lvi.SubItems.Add(move.RelatedMove == null ? "---" : "+++"); _lvi.Tag = move; listView1.Items.Add(_lvi); }
public void RollbackMove(FlingMove move) { if (move.MoveCount > 1) { move.StartBall.Shape = this.m_defaultShape; Cell _end = move.HitBall; base.Cells.RoverCell(ref _end, move.Dir, -1); _end.Shape = CellShapes.empty; } if (move.RelatedMove != null) { this.RollbackMove(move.RelatedMove); } else { move.HitBall.Shape = this.m_defaultShape; } base.RefreshBoard(); }
public void SelectMove(FlingMove move, bool forRoleback) { this.m_selectedMove = move; this.m_selectedForRoleback = forRoleback; base.RefreshBoard(); }
public void SelectMove(FlingMove move) { this.SelectMove(move, false); }