Exemplo n.º 1
0
        public static RubiksCube CreateRubiksCube(Vector3D origin, int cubieNum, double cubieSize, OneOpDone oneOpDone, IFactory factory)
        {
            //if(cubieNum!=3) throw new ArgumentException("Invalid CubieNum");
            RubiksCube rubiksCube = new RubiksCube();

            rubiksCube.CubieSize  = cubieSize;
            rubiksCube._model     = factory.CreateModel();
            rubiksCube._oneOpDone = oneOpDone;
            CubeSize size = new CubeSize(cubieNum, cubieNum, cubieNum);

            rubiksCube.CubeSize = size;
            Vector3D start = origin;

            start.X -= (size.Width - 1) * cubieSize / 2;
            start.Y -= (size.Height - 1) * cubieSize / 2;
            start.Z -= (size.Depth - 1) * cubieSize / 2;
            Vector3D min = origin; min.X -= size.Width * cubieSize / 2; min.Y -= size.Height * cubieSize / 2; min.Z -= size.Depth * cubieSize / 2;
            Vector3D max = origin; max.X += size.Width * cubieSize / 2; max.Y += size.Height * cubieSize / 2; max.Z += size.Depth * cubieSize / 2;

            rubiksCube.BoundingBox = new BoundingBox3D(min, max);

            for (int i = 0; i < size.Width; i++)
            {
                for (int j = 0; j < size.Height; j++)
                {
                    for (int k = 0; k < size.Depth; k++)
                    {
                        //if (k == 0 || j == 0) //for debug
                        {
                            Vector3D cubieOri = start;
                            cubieOri.X += i * cubieSize; cubieOri.Y += j * cubieSize; cubieOri.Z += k * cubieSize;
                            string cubicleName = CubeConfiguration.GetCubicleName(size, i, j, k);
                            //Debug.WriteLine(string.Format("({0},{1},{2}): {3}", i,j,k, cubicleName));
                            if (!string.IsNullOrEmpty(cubicleName))
                            {
                                string  cubieName = cubicleName; //solved configuration
                                Cubicle cubicle   = Cubicle.CreateCubicle(cubicleName, cubieName, cubieOri, cubieSize, factory);
                                rubiksCube._cubicles.Add(cubicleName, cubicle);
                            }
                        }
                    }
                }
            }
            return(rubiksCube);
        }
Exemplo n.º 2
0
 public CubeInteraction(RubiksCube cube)
 {
     _rubikscube = cube;
 }