Beispiel #1
0
        public void RotateFaceACW90(FacePanel face, RotationDirection direction)
        {
            if (direction == RotationDirection.reverse)
            {
                RotateFaceCW90(face, RotationDirection.normal);
                return;
            }

            FaceletData[] a = new FaceletData[4];

            // The outer edge.

            a[0] = face.faceletData[0, 0];
            a[1] = face.faceletData[4, 0];
            a[2] = face.faceletData[4, 4];
            a[3] = face.faceletData[0, 4];
            CycleFacelets4A(a);

            a[0] = face.faceletData[1, 0];
            a[1] = face.faceletData[4, 1];
            a[2] = face.faceletData[3, 4];
            a[3] = face.faceletData[0, 3];
            CycleFacelets4A(a);

            a[0] = face.faceletData[2, 0];
            a[1] = face.faceletData[4, 2];
            a[2] = face.faceletData[2, 4];
            a[3] = face.faceletData[0, 2];
            CycleFacelets4A(a);

            a[0] = face.faceletData[3, 0];
            a[1] = face.faceletData[4, 3];
            a[2] = face.faceletData[1, 4];
            a[3] = face.faceletData[0, 1];
            CycleFacelets4A(a);

            // The inner square

            a[0] = face.faceletData[1, 1];
            a[1] = face.faceletData[3, 1];
            a[2] = face.faceletData[3, 3];
            a[3] = face.faceletData[1, 3];
            CycleFacelets4A(a);

            a[0] = face.faceletData[2, 1];
            a[1] = face.faceletData[3, 2];
            a[2] = face.faceletData[2, 3];
            a[3] = face.faceletData[1, 2];
            CycleFacelets4A(a);

            // Now, rotate the facelets about their centres.

            for (int x = 0; x < 5; x++)
            {
                for (int y = 0; y < 5; y++)
                {
                    face.faceletData[x, y].facelet.transform.Rotate(0.0f, 0.0f, 90.0f);
                }
            }
        }
Beispiel #2
0
        // Z axis

        // nSlice = 0 is Front. nSlice = 4 is Back.
        public void CycleSliceFromFront(int nSlice, RotationDirection direction)
        {
            FaceletData[] a = new FaceletData[20];

            a[0] = downPanel.faceletData[0, 4 - nSlice];
            a[1] = downPanel.faceletData[1, 4 - nSlice];
            a[2] = downPanel.faceletData[2, 4 - nSlice];
            a[3] = downPanel.faceletData[3, 4 - nSlice];
            a[4] = downPanel.faceletData[4, 4 - nSlice];

            a[5] = rightPanel.faceletData[nSlice, 0];
            a[6] = rightPanel.faceletData[nSlice, 1];
            a[7] = rightPanel.faceletData[nSlice, 2];
            a[8] = rightPanel.faceletData[nSlice, 3];
            a[9] = rightPanel.faceletData[nSlice, 4];

            a[10] = upPanel.faceletData[4, nSlice];
            a[11] = upPanel.faceletData[3, nSlice];
            a[12] = upPanel.faceletData[2, nSlice];
            a[13] = upPanel.faceletData[1, nSlice];
            a[14] = upPanel.faceletData[0, nSlice];

            a[15] = leftPanel.faceletData[4 - nSlice, 4];
            a[16] = leftPanel.faceletData[4 - nSlice, 3];
            a[17] = leftPanel.faceletData[4 - nSlice, 2];
            a[18] = leftPanel.faceletData[4 - nSlice, 1];
            a[19] = leftPanel.faceletData[4 - nSlice, 0];

            if (direction == RotationDirection.normal)
            {
                a[4].facelet.transform.Rotate(0.0f, 0.0f, 90.0f);
                a[9].facelet.transform.Rotate(0.0f, 0.0f, 90.0f);
                a[14].facelet.transform.Rotate(0.0f, 0.0f, 90.0f);
                a[19].facelet.transform.Rotate(0.0f, 0.0f, 90.0f);

                CycleFacelets20A(a);
            }
            else
            {
                a[0].facelet.transform.Rotate(0.0f, 0.0f, -90.0f);
                a[5].facelet.transform.Rotate(0.0f, 0.0f, -90.0f);
                a[10].facelet.transform.Rotate(0.0f, 0.0f, -90.0f);
                a[15].facelet.transform.Rotate(0.0f, 0.0f, -90.0f);

                CycleFacelets20(a);
            }
        }
Beispiel #3
0
        FaceletData CreateFacelet(int x, int y, Color col)
        {
            FaceletData faceletData = new FaceletData();

            float xTrans = (x - 2) * 40.0f;
            float yTrans = (y - 2) * 40.0f;

            if (inverted)
            {
                x = 4 - x;
                y = 4 - y;
            }

            string codeNumber = string.Format("{0}{1}", x, y);
            string codeName   = "Facelet" + codeNumber;

            GameObject facelet = DefaultControls.CreatePanel(uiResources);

            faceletData.facelet = facelet;

            facelet.name = codeName;
            facelet.transform.SetParent(panelFace.transform, false);

            Image img = facelet.GetComponent <Image>();

            img.color = col;

            if (inverted)
            {
                img.sprite = panelMap.faceSpritesInverted[x, y];
                faceletData.spriteNumber = panelMap.faceSpritesInverted[x, y];
            }
            else
            {
                img.sprite = panelMap.faceSprites[x, y];
                faceletData.spriteNumber = panelMap.faceSprites[x, y];
            }

            RectTransform rt = facelet.GetComponent <RectTransform>();

            rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 40.0f);
            rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40.0f);

            rt.Translate(xTrans, yTrans, 0.0f);

            return(faceletData);
        }
Beispiel #4
0
        // Y axis

        // nSlice = 0 is Top. nSlice = 4 is Bottom.
        public void CycleSliceFromTop(int nSlice, RotationDirection rotationDirection)
        {
            FaceletData[] a = new FaceletData[20];    // An array of the little "facelet" panels.

            a[0] = frontPanel.faceletData[0, 4 - nSlice];
            a[1] = frontPanel.faceletData[1, 4 - nSlice];
            a[2] = frontPanel.faceletData[2, 4 - nSlice];
            a[3] = frontPanel.faceletData[3, 4 - nSlice];
            a[4] = frontPanel.faceletData[4, 4 - nSlice];

            a[5] = rightPanel.faceletData[0, 4 - nSlice];
            a[6] = rightPanel.faceletData[1, 4 - nSlice];
            a[7] = rightPanel.faceletData[2, 4 - nSlice];
            a[8] = rightPanel.faceletData[3, 4 - nSlice];
            a[9] = rightPanel.faceletData[4, 4 - nSlice];

            a[10] = backPanel.faceletData[4, nSlice];
            a[11] = backPanel.faceletData[3, nSlice];
            a[12] = backPanel.faceletData[2, nSlice];
            a[13] = backPanel.faceletData[1, nSlice];
            a[14] = backPanel.faceletData[0, nSlice];

            a[15] = leftPanel.faceletData[0, 4 - nSlice];
            a[16] = leftPanel.faceletData[1, 4 - nSlice];
            a[17] = leftPanel.faceletData[2, 4 - nSlice];
            a[18] = leftPanel.faceletData[3, 4 - nSlice];
            a[19] = leftPanel.faceletData[4, 4 - nSlice];

            if (rotationDirection == RotationDirection.normal)
            {
                a[10].facelet.transform.Rotate(0.0f, 0.0f, 180.0f);
                a[15].facelet.transform.Rotate(0.0f, 0.0f, 180.0f);

                CycleFacelets20(a);
            }
            else
            {
                a[14].facelet.transform.Rotate(0.0f, 0.0f, 180.0f);
                a[9].facelet.transform.Rotate(0.0f, 0.0f, 180.0f);

                CycleFacelets20A(a);
            }
        }
Beispiel #5
0
        //----------------------------------------------------

        // X axis

        // nSlice = 0 is Right. nSlice = 4 is Left.
        public void CycleSliceFromRight(int nSlice, RotationDirection rotationDirection)
        {
            FaceletData[] a = new FaceletData[20];

            a[0] = frontPanel.faceletData[4 - nSlice, 0];
            a[1] = frontPanel.faceletData[4 - nSlice, 1];
            a[2] = frontPanel.faceletData[4 - nSlice, 2];
            a[3] = frontPanel.faceletData[4 - nSlice, 3];
            a[4] = frontPanel.faceletData[4 - nSlice, 4];

            a[5] = upPanel.faceletData[4 - nSlice, 0];
            a[6] = upPanel.faceletData[4 - nSlice, 1];
            a[7] = upPanel.faceletData[4 - nSlice, 2];
            a[8] = upPanel.faceletData[4 - nSlice, 3];
            a[9] = upPanel.faceletData[4 - nSlice, 4];

            a[10] = backPanel.faceletData[4 - nSlice, 0];
            a[11] = backPanel.faceletData[4 - nSlice, 1];
            a[12] = backPanel.faceletData[4 - nSlice, 2];
            a[13] = backPanel.faceletData[4 - nSlice, 3];
            a[14] = backPanel.faceletData[4 - nSlice, 4];

            a[15] = downPanel.faceletData[4 - nSlice, 0];
            a[16] = downPanel.faceletData[4 - nSlice, 1];
            a[17] = downPanel.faceletData[4 - nSlice, 2];
            a[18] = downPanel.faceletData[4 - nSlice, 3];
            a[19] = downPanel.faceletData[4 - nSlice, 4];

            if (rotationDirection == RotationDirection.normal)
            {
                CycleFacelets20A(a);
            }
            else
            {
                CycleFacelets20(a);
            }
        }