Пример #1
0
        public void handleUp(int x, int y)
        {
            if (lastClicked.position.X == 0)
            {
                Matrices.isSolved(matrix);
            }
            Sticker target = null;

            foreach (Sticker[] array in matrix)
            {
                foreach (Sticker sticker in array)
                {
                    sticker.reset();
                    if (sticker.hit(x, y))
                    {
                        target = sticker;
                    }
                }
            }
            if (lastClicked != null && target != null)
            {
                Matrices.makeMove(matrix, lastClicked, target);
            }
            lastClicked = null;
            cubeWatcher.notify();
        }
Пример #2
0
 Cube(Observer obs)
 {
     cubeWatcher = obs;
     cubeWatcher.sub(this);
     matrix = new Sticker[9][];
     for (int i = 0; i < 9; i++)
     {
         matrix[i] = new Sticker[9];
     }
     Matrices.initialize(matrix, cubeWatcher);
 }
Пример #3
0
        public void scramble()
        {
            Random rng = new Random();

            for (int i = 0; i < 50; i++)
            {
                int row    = rng.Next(2);
                int first  = rng.Next(9);
                int second = rng.Next(9);
                int third  = rng.Next(9);
                if (row == 0)
                {
                    Matrices.makeMove(matrix, matrix[first][second], matrix[first][third]);
                }
                else
                {
                    Matrices.makeMove(matrix, matrix[first][second], matrix[third][second]);
                }
            }
            cubeWatcher.notify();
        }
Пример #4
0
 public bool isSolved()
 {
     return(Matrices.isSolved(matrix));
 }