コード例 #1
0
        public void MixUpPuzzle()
        {
            _puzzleLogic.MixUpPuzzle();

            short cellNumber = 1;

            foreach (Button b in this.Children)
            {
                PuzzleCell location = _puzzleLogic.FindCell(cellNumber++);
                b.SetValue(Grid.ColumnProperty, location.Col);
                b.SetValue(Grid.RowProperty, location.Row);
            }
        }
コード例 #2
0
        // Assumed to be a valid move.
        private void MovePiece(Button b, int row, int col)
        {
            PuzzleCell newPosition = _puzzleLogic.MovePiece(row, col);

            b.SetValue(Grid.ColumnProperty, newPosition.Col);
            b.SetValue(Grid.RowProperty, newPosition.Row);

            if (_puzzleLogic.CheckForWin())
            {
                if (PuzzleWon != null)
                {
                    PuzzleWon(this, EventArgs.Empty);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Moves the piece
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns>The cell of the newly opened position</returns>
        public PuzzleCell MovePiece(int row, int col)
        {
            Debug.Assert(GetMoveStatus(row, col) != MoveStatus.BadMove);

            PuzzleCell cell = new PuzzleCell(_emptyRow, _emptyCol, EMPTY_CELL_ID);

            short origCell = _cells[row, col];

            _cells[_emptyRow, _emptyCol] = origCell;
            _cells[row, col]             = EMPTY_CELL_ID;

            _emptyCol = col;
            _emptyRow = row;


            return(cell);
        }
コード例 #4
0
ファイル: puzzlelogic.cs プロジェクト: khmurox/KhGitHubTest
        /// <summary>
        /// Moves the piece
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns>The cell of the newly opened position</returns>
        public PuzzleCell MovePiece(int row, int col)
        {
            Debug.Assert(GetMoveStatus(row, col) != MoveStatus.BadMove);

            PuzzleCell cell = new PuzzleCell(_emptyRow, _emptyCol, EMPTY_CELL_ID);

            short origCell = _cells[row, col];

            _cells[_emptyRow, _emptyCol] = origCell;
            _cells[row, col] = EMPTY_CELL_ID;

            _emptyCol = col;
            _emptyRow = row;

            return cell;
        }