Ejemplo n.º 1
0
        public static IRubiksCube Clockwise(IRubiksCube cube, IFace face)
        {
        return new RubiksCube(
            getF: coordinate =>
            {
                if (coordinate.Face.Equals(face))
                {
                    return cube[new Coordinate(coordinate.Face, Rotate(coordinate.Position))];
                }

                var direction = face.Diff(coordinate.Face);

                if (direction != null)
                {
                    // WTF???

                    var rotated = Rotate(direction);
                    var before = face.Neighbour(rotated);

                    for (int index = -1; index < 2; index++)
                    {
                        if (coordinate.Position.Equals(face.Matching(direction, index)))
                        {
                            var relative = coordinate.Face.Diff(before);

                            coordinate = coordinate.Travel(ref relative, count: 3);

                            return cube[coordinate];
                        }
                    }
                }

                return cube[coordinate];
            });
        }
Ejemplo n.º 2
0
 public static void Check(this IRubiksCube cube)
 {
     foreach (Colors color in Enum.GetValues(typeof(Colors)))
     {
         if (Count(cube, color) != 9)
         {
             throw new ArgumentException();
         }
     }
 }
Ejemplo n.º 3
0
        public void SerializeToStore(IRubiksCube cube)
        {
            var sb = new StringBuilder();

            foreach (var data in cube.GetStickerData())
            {
                sb.Append(data.ToString());

                sb.Append(Separator);
            }

            store.SetString(StoreKey, sb.ToString().Base64Encode());
        }
Ejemplo n.º 4
0
        public static uint Count(IRubiksCube cube, Colors color)
        {
            uint count = 0;

            foreach (Columns column in Enum.GetValues(typeof(Columns)))
            {
                foreach (Rows row in Enum.GetValues(typeof(Rows)))
                {
                    foreach (Axis axis in Enum.GetValues(typeof(Axis)))
                    {
                        foreach (Orientation orientation in Enum.GetValues(typeof(Orientation)))
                        {
                            if (cube[new Coordinate(new Face(axis, orientation), new Position(column, row))] == color)
                            {
                                count++;
                            }
                        }
                    }
                }
            }

            return count;
        }
Ejemplo n.º 5
0
        public PlayingState(StateContext context, ITinyMessengerHub messengerHub, ILogger logger, IRubiksCube cube, ITimer timer, ICubeSolvedChecker cubeSolvedChecker)
            : base(context, messengerHub, logger, cube)
        {
            this.timer             = timer;
            this.cubeSolvedChecker = cubeSolvedChecker;

            inGameScreen = new InGameScreen(messengerHub, timer);

            inGameScreen.Build();

            inGameScreen.TimerIsVisible = Context.Store.GetBool(keyTimerVisible, true);
        }
Ejemplo n.º 6
0
 public SolvedState(StateContext context, ITinyMessengerHub messengerHub, ILogger logger, IRubiksCube rubiksCube,
                    TimeSpan timeToSolve) : base(context, messengerHub, logger, rubiksCube)
 {
     screen = new EndGameScreen(timeToSolve, this);
 }
Ejemplo n.º 7
0
        public ScramblingState(StateContext context, ITinyMessengerHub messengerHub, ILogger logger, IRubiksCube cube,
                               ILightLevelController lightLevelController) : base(context, messengerHub, logger, cube)
        {
            this.lightLevelController = lightLevelController;

            randomPointVariance = RubiksCube.PiecesPerRow * 0.5f;

            sliceFinders = new List <SliceFinder>(3)
            {
                RubiksCube.FindXAxisSlice,
                RubiksCube.FindYAxisSlice,
                RubiksCube.FindZAxisSlice,
            };
        }
Ejemplo n.º 8
0
 protected CubeGameStateBase(StateContext context, ITinyMessengerHub messengerHub, ILogger logger, IRubiksCube rubiksCube)
     : base(context, messengerHub, logger)
 {
     RubiksCube = rubiksCube;
 }