Exemplo n.º 1
0
 public FifteenModel()
 {
     ClickCommand = new DelegateCommand<Cell>(Clicked);
     Cells = new Cell[AreaSize * AreaSize - 1];
     NullCell = new Cell(0);
     CreateArea();
     SetPositions();
     SetRandomArea();
 }
Exemplo n.º 2
0
 private void CreateArea()
 {
     for (int i = 0; i < 15; i++)
     {
         Cells[i] = new Cell(i + 1);
     }
 }
Exemplo n.º 3
0
 private void Clicked(Cell cell)
 {
     Clicked(cell, true);
 }
Exemplo n.º 4
0
 private void Clicked(Cell cell, bool userCall)
 {
     if (!CellCanMove(cell))
         return;
     var nullCellRow = NullCell.Row;
     var nullCellColumn = NullCell.Column;
     NullCell.Row = cell.Row;
     NullCell.Column = cell.Column;
     cell.Row = nullCellRow;
     cell.Column = nullCellColumn;
     if (userCall && Finished())
         GameFinished();
 }
Exemplo n.º 5
0
 private bool CellCanMove(Cell cell)
 {
     return Math.Abs(cell.Column - NullCell.Column) + Math.Abs(cell.Row - NullCell.Row) == 1;
 }