Exemplo n.º 1
0
        public static async Task<CubeRotation> PositionOnBottom(CubeConfiguration<FaceColour> config, FaceType face)
        {
            CubeRotation cubeRotation;

            switch (face)
            {
                case FaceType.Down:
                    return null;

                case FaceType.Upper:
                    cubeRotation = CubeRotations.X2;
                    break;

                case FaceType.Right:
                    cubeRotation = CubeRotations.ZClockwise;
                    break;

                case FaceType.Left:
                    cubeRotation = CubeRotations.ZAntiClockwise;
                    break;

                case FaceType.Front:
                    cubeRotation = CubeRotations.XAntiClockwise;
                    break;

                case FaceType.Back:
                    cubeRotation = CubeRotations.XClockwise;
                    break;

                default:
                    throw new Exception("Unknown face");
            }

            await config.RotateCube(cubeRotation).ConfigureAwait(false);
            return cubeRotation;
        }
Exemplo n.º 2
0
        public static async Task<CubeRotation> PositionOnFront(CubeConfiguration<FaceColour> config, FaceColour faceColour)
        {
            var face = FindFaceWithCentreColour(config, faceColour);
            CubeRotation cubeRotation;

            switch (face)
            {
                case FaceType.Front:
                    return null;

                case FaceType.Upper:
                    cubeRotation = CubeRotations.XAntiClockwise;
                    break;

                case FaceType.Right:
                    cubeRotation = CubeRotations.YClockwise;
                    break;

                case FaceType.Left:
                    cubeRotation = CubeRotations.YAntiClockwise;
                    break;

                case FaceType.Down:
                    cubeRotation = CubeRotations.XClockwise;
                    break;

                case FaceType.Back:
                    cubeRotation = CubeRotations.Y2;
                    break;

                default:
                    throw new Exception("Unknown face");
            }

            await config.RotateCube(cubeRotation).ConfigureAwait(false);
            return cubeRotation;
        }
Exemplo n.º 3
0
        public static void ApplyRotations(IEnumerable<IRotation> rotations, CubeConfiguration<FaceColour> configuration)
        {
            foreach (var rotation in rotations)
            {
                var cubeRotation = rotation as CubeRotation;
                var faceRotation = rotation as FaceRotation;

                if (cubeRotation != null)
                {
                    configuration.RotateCube(cubeRotation).Wait();
                }
                if (faceRotation != null)
                {
                    configuration.Rotate(faceRotation).Wait();
                }
            }
        }