Пример #1
0
        public void Rotate(Vector3 side, bool isClockWise, string algOrder)
        {
            Angle -= RotationSpeed;
            float sidePosition = Main.CubieSize;
            //Debug.WriteLine("animAngle=     " + Angle);
            //Debug.WriteLine("Angle " + MathHelper.ToRadians(Angle));
            float partOfRotation = (float)(100f / RotationSpeed);

            //Debug.WriteLine(partOfRotation + " = part");
            if (side == Vector3.Left)
            {
                howManyTurns++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    //Debug.WriteLine(i);
                    if (isClockWise)
                    {
                        RotateSide(i, MathHelper.PiOver2 / partOfRotation, 1.5f * sidePosition, -1.5f * sidePosition, 0, 'x');
                    }
                    else
                    {
                        RotateSide(i, -MathHelper.PiOver2 / partOfRotation, 1.5f * sidePosition, -1.5f * sidePosition, 0, 'x');
                    }
                }
            }
            else if (side == Vector3.Right)
            {
                howManyTurns++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (isClockWise)
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, -1.5f * sidePosition, -1.5f * sidePosition, 0, 'x');
                    }
                    else
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, -1.5f * sidePosition, -1.5f * sidePosition, 0, 'x');
                    }
                }
            }
            else if (side == Vector3.Up)
            {
                howManyTurns++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (isClockWise)
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, 0, 0, 0, 'y');
                    }
                    else
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, 0, 0, 0, 'y');
                    }
                }
            }
            else if (side == Vector3.Down)
            {
                howManyTurns++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (isClockWise)
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, 0, 0, 0, 'y');
                    }
                    else
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, 0, 0, 0, 'y');
                    }
                }
            }
            else if (side == Vector3.Forward)
            {
                howManyTurns++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (!isClockWise)
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, 0, -1.5f * sidePosition, -1.5f * sidePosition, 'z');
                    }
                    else
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, 0, -1.5f * sidePosition, 1.5f * sidePosition, 'z');
                    }
                }
            }
            else if (side == Vector3.Backward)
            {
                howManyTurns++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (!isClockWise)
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, 0, -1.5f * sidePosition, 1.5f * sidePosition, 'z');
                    }
                    else
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, 0, -1.5f * sidePosition, -1.5f * sidePosition, 'z');
                    }
                }
            }
            if (howManyTurns == (110 - RotationSpeed) / 10)
            {
                //cubeConfig.CheckFaceColor();
                cubeConfig.Rotate(side, isClockWise);
                //cubeConfig.CheckFaceColor();
                cubeState.Rotate(side, isClockWise);
                howManyTurns = 0;
            }
        }
Пример #2
0
        public void Rotate(Vector3 side, bool isClockWise, string algOrder)
        {
            const float sidePosition = Game1.CUBIE_SIZE;

            Angle -= RotationSpeed;
            //Debug.WriteLine("animAngle=     " + Angle);
            //Debug.WriteLine("Angle " + MathHelper.ToRadians(Angle));
            if (side == Vector3.Left)
            {
                counter++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    Debug.WriteLine(i);
                    if (isClockWise)
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, 1.5f * sidePosition, -1.5f * sidePosition, 0, 'x');
                    }
                    else
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, 1.5f * sidePosition, -1.5f * sidePosition, 0, 'x');
                    }
                }
            }
            else if (side == Vector3.Right)
            {
                counter++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (isClockWise)
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, -1.5f * sidePosition, -1.5f * sidePosition, 0, 'x');
                    }
                    else
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, -1.5f * sidePosition, -1.5f * sidePosition, 0, 'x');
                    }
                }
            }
            else if (side == Vector3.Up)
            {
                counter++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (isClockWise)
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, 0, 0, 0, 'y');
                    }
                    else
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, 0, 0, 0, 'y');
                    }
                }
            }
            else if (side == Vector3.Down)
            {
                counter++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (isClockWise)
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, 0, 0, 0, 'y');
                    }
                    else
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, 0, 0, 0, 'y');
                    }
                }
            }
            else if (side == Vector3.Forward)
            {
                counter++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (isClockWise)
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, 0, -1.5f * sidePosition, -1.5f * sidePosition, 'z');
                    }
                    else
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, 0, -1.5f * sidePosition, 1.5f * sidePosition, 'z');
                    }
                }
            }
            else if (side == Vector3.Backward)
            {
                counter++;
                foreach (int i in cubeState.FindCubiesOnSide(side, isClockWise))
                {
                    if (isClockWise)
                    {
                        RotateSide(i, MathHelper.PiOver2 / 10f, 0, -1.5f * sidePosition, 1.5f * sidePosition, 'z');
                    }
                    else
                    {
                        RotateSide(i, -MathHelper.PiOver2 / 10f, 0, -1.5f * sidePosition, -1.5f * sidePosition, 'z');
                    }
                }
            }
            if (counter == 10)
            {
                if ((side == Vector3.Backward || side == Vector3.Forward))
                {
                    if (isClockWise)
                    {
                        isClockWise = false;
                    }
                    else
                    {
                        isClockWise = true;
                    }
                }
                cubeState.Rotate(side, isClockWise);
                counter = 0;
            }
        }