예제 #1
0
        public Boolean readFromFile(RubikFileReader p_reader)
        {
            int l_int;

            l_int = p_reader.read();
            //Console.Write("%d ",l_int);
            while ((l_int == ' ') || (l_int == 13 /*'\r'*/))
            {
                l_int = p_reader.read();
                // Console.Write("%d ",l_int);
            }

            if ((l_int == /*'\n'*/ 10) || (l_int == -1 /*EOF*/) || (l_int != '('))
            {
                return(false);
            }
            else
            {
                c_face = FaceHandler.getFace((int)Char.GetNumericValue((char)(p_reader.read())));
                p_reader.read();
                c_direction = DirectionHandler.getDirection((int)Char.GetNumericValue((char)(p_reader.read())));
                p_reader.read();
                return(true);
            }
        }
예제 #2
0
 public String getString()
 {
     if (c_isEdge)
     {
         return(String.Format("{0}, {1}", FaceHandler.getCharValue(c_face0), FaceHandler.getCharValue(c_face1)));
     }
     else
     {
         return(String.Format("{0}, {1}, {2}", FaceHandler.getCharValue(c_face0), FaceHandler.getCharValue(c_face1), FaceHandler.getCharValue(c_face2)));
     }
 }
예제 #3
0
 public Rotation(int p_value)
 {
     if (p_value > 5)
     {
         c_direction = DirectionFactory.getDirectionByInt(1);
         c_face      = FaceHandler.getFace(p_value - 6);
     }
     else
     {
         c_direction = DirectionFactory.getDirectionByInt(0);
         c_face      = FaceHandler.getFace(p_value);
     }
 }
예제 #4
0
 public Face getFace(Face p_viewpoint)
 {
     if (p_viewpoint == Face.TOP)
     {
         return(c_currentUp);
     }
     else if (p_viewpoint == Face.BOTTOM)
     {
         return(FaceHandler.getOpposite(c_currentUp));
     }
     else
     {
         return(getHorizonalFacebyVirtual(p_viewpoint));
     }
 }
예제 #5
0
        public void rotate(Rotation p_rotation)
        {
            Face      l_temp;
            Face      l_face      = p_rotation.getFace();
            Direction l_direction = p_rotation.getDirection();

            if (l_face == Face.TOP)
            {
                if (l_direction == Direction.CW)
                {
                    c_currentFront = getFace(Face.RIGHT);
                }
                else
                {
                    c_currentFront = getFace(Face.LEFT);
                }
            }
            else if (l_face == Face.RIGHT)
            {
                if (l_direction == Direction.CW)
                {
                    l_temp         = c_currentFront;
                    c_currentFront = getFace(Face.BOTTOM);
                    c_currentUp    = l_temp;
                }
                else
                {
                    l_temp         = getFace(Face.BACK);
                    c_currentFront = c_currentUp;
                    c_currentUp    = l_temp;
                }
            }
            else if (l_face == Face.FRONT)
            {
                if (l_direction == Direction.CW)
                {
                    c_currentUp = getFace(Face.LEFT);
                }
                else
                {
                    c_currentUp = getFace(Face.RIGHT);
                }
            }
            else
            {
                rotate(new Rotation(FaceHandler.getOpposite(l_face), DirectionHandler.getOpposite(l_direction)));
            }
        }
예제 #6
0
 public String getString()
 {
     return(String.Format("{0}, {1}", FaceHandler.getCharValue(c_currentUp), FaceHandler.getCharValue(c_currentFront)));
 }
예제 #7
0
 public void print()
 {
     Console.Write("({0},{1})", FaceHandler.getCharValue(c_face), DirectionHandler.getString(c_direction));
 }