Beispiel #1
0
        public void KeyDown(KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Up:
                MoveEvent.Up(matrix_box);
                break;

            case Key.Down:
                MoveEvent.Down(matrix_box);
                break;

            case Key.Left:
                MoveEvent.Left(matrix_box);
                break;

            case Key.Right:
                MoveEvent.Right(matrix_box);
                break;

            default:
                break;
            }
            if (Checker.IsTrue(matrix_box, rows, cols))
            {
                SetGrid.SetDefault(gridPlay);
                SetGrid.SetImage(gridPlay, image);
            }
        }
Beispiel #2
0
 private void Box_Click(object sender, RoutedEventArgs e, Box box, Grid gridPlay)
 {
     MoveEvent.Click(box);
     if (Checker.IsTrue(this, rows, cols))
     {
         SetGrid.SetDefault(gridPlay);
         SetGrid.SetImage(gridPlay, image);
     }
 }
Beispiel #3
0
        public async void Play(MatrixBox matrix_box, Grid gridPlay)
        {
            long[,] matrix = new long[3, 3];
            for (long i = 0; i < 3; ++i)
            {
                for (long j = 0; j < 3; ++j)
                {
                    matrix[i, j] = -1;
                }
            }
            for (long i = 0; i < 3; ++i)
            {
                for (long j = 0; j < 3; ++j)
                {
                    if (i == 2 && j == 2)
                    {
                        break;
                    }
                    matrix[matrix_box.matrix[i, j].curr_row, matrix_box.matrix[i, j].curr_col] = i * 3 + j;
                }
            }
            for (long i = 0; i < 3; ++i)
            {
                for (long j = 0; j < 3; ++j)
                {
                    if (matrix[i, j] == -1)
                    {
                        matrix[i, j] = 8;
                    }
                }
            }

            long _curr = tree[ToInt(matrix)];

            while (_curr != 0)
            {
                long _x = (_curr - 1) % 4;
                MoveEvent.Move(matrix_box, (-1) * X[_x], (-1) * Y[_x]);
                await Task.Delay(500);

                _curr = (_curr - 1) / 4;
            }
            SetGrid.SetDefault(gridPlay);
            SetGrid.SetImage(gridPlay, matrix_box.image);
        }
Beispiel #4
0
 public void Fill(Grid gridPlay)
 {
     SetGrid.SetDefault(gridPlay);
     SetGrid.SetRowDef(gridPlay, rows);
     SetGrid.SetColumnDef(gridPlay, cols);
     for (int i = 0; i < rows; ++i)
     {
         for (int j = 0; j < cols; ++j)
         {
             int u = i, v = j;
             if (i == rows - 1 && j == cols - 1)
             {
                 break;
             }
             int r = shuffle_array[i * cols + j] / cols;
             int c = shuffle_array[i * cols + j] % cols;
             matrix[i, j] = new Box(matrix_image.Matrix[i, j], r, c, i, j);
             Grid.SetRow(matrix[i, j].box, r);
             Grid.SetColumn(matrix[i, j].box, c);
             matrix[i, j].box.Click += new RoutedEventHandler((sender, e) => Box_Click(sender, e, matrix[u, v], gridPlay));
             gridPlay.Children.Add(matrix[i, j].box);
         }
     }
 }