Ejemplo n.º 1
0
    public void Solver()
    {
        readCube.ReadState();

        //지금상태를 스트링으로받고
        string moveString = cubeState.GetStateString();

        print(moveString);
        //큐브를풀고



        string info = "";
        //SearchRunTime,Search 모두 코시엠바 클래스


        string solution = Search.solution(moveString, out info);

        if (justOne)
        {
            solution = SearchRunTime.solution(moveString, out info, buildTables: true);
            justOne  = false;
        }


        List <string> solutionList = StringToList(solution); //코시엠바 해답에서 공백을빼고 정리함

        Automate.moveList = solutionList;                    //무브리스트에 리스트를 새로넣어서 업데이트에서 자동으로돌아감
        //해법무빙을 리스트로받고
        //Automate에 리스트넣고
    }
    public void Solver()
    {
        readCube.ReadState();

        //Get the State of the cube as a string
        string moveString = cubeState.GetStateString();

        Debug.Log(moveString);

        //Solve the Cube

        string info = "";

        //First Time Build the Tables
        //string solution = SearchRunTime.solution(moveString, out info, buildTables: true);

        //Every other time
        string solution = Search.solution(moveString, out info);


        //Convert the Solved Moves from a string to a list
        List <string> solutionList = StringToList(solution);


        //Automate the List
        Automate.moveList = solutionList;
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !CubeState.autoRotating)
        {
            //Read Current State of Cube
            readCube.ReadState();

            //RayCast from the mouse towards the cube to see if a face is hit
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, 100.0f, layerMask))
            {
                GameObject face = hit.collider.gameObject;
                //Make a List of all the Sides
                List <List <GameObject> > cubeSides = new List <List <GameObject> >()
                {
                    cubeState.up,
                    cubeState.down,
                    cubeState.left,
                    cubeState.right,
                    cubeState.front,
                    cubeState.back
                };
                foreach (List <GameObject> cubeSide in cubeSides)
                {
                    if (cubeSide.Contains(face))
                    {
                        cubeState.PickUp(cubeSide);

                        cubeSide[4].transform.parent.GetComponent <PivotRotation>().Rotate(cubeSide);
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
    public void Solver()
    {
        readCube.ReadState();
        //get faces state of the cube as a string
        string moveString = cubeState.GetStateString();

        print(moveString);

        //solve the cube
        string info = "";
        //Fist time build the tables

        string solution = SearchRunTime.solution(moveString, out info, buildTables: true);

        //Every other time
        //string solution = Search.solution(moveString, out info);

        //convert the solved moves from a string to a list
        List <string> solutionList = StringToList(solution);

        //Automate the list
        Automate.moveList = solutionList;
        print("hi");
        print(info);
    }
Ejemplo n.º 5
0
    private void AutoRotate()
    {
        dragging = false;
        var step = speed * Time.deltaTime;

        transform.localRotation = Quaternion.RotateTowards(transform.localRotation, targetQuaternion, step);
        if (Quaternion.Angle(transform.localRotation, targetQuaternion) <= 1)
        {
            transform.localRotation = targetQuaternion;

            cubeState.PutDown(activeSide, transform.parent);
            readCube.ReadState();
            CubeState.autoRotating = false;
            autoRotating           = false;
            dragging = false;
        }
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        //&& !CubeState.autoRotating
        if (!CubeState.autoRotating)
        {
            if (Input.GetMouseButtonDown(0))
            {
                //지금 큐브상태
                readCube.ReadState(); //패널에 찍어줌

                //2차원 마우스에서 2차원큐브로 레이져쏨 6면중 어느face가 맞았는지 볼수있음
                RaycastHit hit;
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                //지금 ray는 2차원 마우스 찍는포지션
                if (Physics.Raycast(ray, out hit, 100.0f, layerMask))
                {
                    //마우스로 어느면을 클릭한지가 face에 들어감
                    GameObject face = hit.collider.gameObject;

                    //update안에서 눌린동안 한번 cubeState의 6개 리스트를가져옴
                    List <List <GameObject> > cubeSides = new List <List <GameObject> >()
                    {
                        cubeState.up,
                        cubeState.down,
                        cubeState.left,
                        cubeState.right,
                        cubeState.front,
                        cubeState.back
                    };

                    // 레이져쏴서 맞는게나온다면이라는 조건문후에 나오는 for문
                    foreach (List <GameObject> cubeSide in cubeSides)
                    {
                        //cubeSide는 하나하나가cubeState.up,cubeState.down, ..6개순서대로
                        if (cubeSide.Contains(face))    //face:마우스 왼쪽클릭한거 2차원
                        {
                            cubeState.PickUp(cubeSide); //픽업함수쓰고
                            cubeSide[4].transform.parent.GetComponent <PivotRotation>().Rotate(cubeSide);
                            //Rotate() 는 피봇스크립트에있음
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 7
0
    private void AutoRotate()
    {
        dragging = false;
        var step = speed * Time.deltaTime;

        transform.localRotation = Quaternion.RotateTowards(transform.localRotation, targetQuaternion, step);
        //if within one degree, set angle to target angle and end the rotation
        if (Quaternion.Angle(transform.localRotation, targetQuaternion) <= 1)
        {
            transform.localRotation = targetQuaternion;
            //unparent the little cubes
            cubeState.PutDown(activeSide, transform.parent);
            readCube.ReadState();
            CubeState.autoRotating = false;
            autoRotating           = false;
            dragging = false;
        }
    }
Ejemplo n.º 8
0
    private void AutoRotate()
    {
        dragging = false; //자동회전중에는 드래그불가
        var step = speed * Time.deltaTime;

        transform.localRotation = Quaternion.RotateTowards(
            transform.localRotation, targetQuarternion, step);
        //1도미만이면 자동시행
        if (Quaternion.Angle(transform.localRotation, targetQuarternion) <= 1)
        {
            transform.localRotation = targetQuarternion;
            //unperant 작은큐브
            cubeState.PutDown(activeSide, transform.parent); //언팔하고
            readCube.ReadState();                            //큐브상태읽어주고
            CubeState.autoRotating = false;
            autoRotating           = false;                  //변수들바꿔주고
            dragging = false;
        }
    }
Ejemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && CubeState.autoRotating == false)
        {
            //take cube current state
            readCube.ReadState();

            //raycast from the mouse towards the cube to see if a face is hit
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, 100.0f, layerMask))
            {
                GameObject face = hit.collider.gameObject;
                //Make a list of gameObjects, with all sides
                List <List <GameObject> > cubeSides = new List <List <GameObject> >()
                {
                    cubeState.up,
                    cubeState.down,
                    cubeState.left,
                    cubeState.right,
                    cubeState.front,
                    cubeState.back
                };
                // If teh face hit exists within a side
                foreach (List <GameObject> cubeSide in cubeSides)
                {
                    if (cubeSide.Contains(face))
                    {
                        print(face);
                        //make it childrens to the side
                        cubeState.PickUp(cubeSide);
                        //start the side rotation logic
                        cubeSide[4].transform.parent.GetComponent <PivitRotation>().Rotate(cubeSide);
                    }
                }
            }
        }
    }
Ejemplo n.º 10
0
 void DoMove(string move)
 {
     readCube.ReadState();
     CubeState.autoRotating = true;
     if (move == "U")
     {
         RotateSide(cubeState.up, -90);
     }
     if (move == "U'")
     {
         RotateSide(cubeState.up, 90);
     }
     if (move == "U2")
     {
         RotateSide(cubeState.up, -180);
     }
     if (move == "D")
     {
         RotateSide(cubeState.down, -90);
     }
     if (move == "D'")
     {
         RotateSide(cubeState.down, 90);
     }
     if (move == "D2")
     {
         RotateSide(cubeState.down, -180);
     }
     if (move == "L")
     {
         RotateSide(cubeState.left, -90);
     }
     if (move == "L'")
     {
         RotateSide(cubeState.left, 90);
     }
     if (move == "L2")
     {
         RotateSide(cubeState.left, -180);
     }
     if (move == "R")
     {
         RotateSide(cubeState.right, -90);
     }
     if (move == "R'")
     {
         RotateSide(cubeState.right, 90);
     }
     if (move == "R2")
     {
         RotateSide(cubeState.right, -180);
     }
     if (move == "F")
     {
         RotateSide(cubeState.front, -90);
     }
     if (move == "F'")
     {
         RotateSide(cubeState.front, 90);
     }
     if (move == "F2")
     {
         RotateSide(cubeState.front, -180);
     }
     if (move == "B")
     {
         RotateSide(cubeState.back, -90);
     }
     if (move == "B'")
     {
         RotateSide(cubeState.back, 90);
     }
     if (move == "B2")
     {
         RotateSide(cubeState.back, -180);
     }
 }
Ejemplo n.º 11
0
    void DoMove(string Move)
    {
        readCube.ReadState();          //시작하자마자 한번읽어줌

        CubeState.autoRotating = true; //자동회전 참으로바꿈

        if (Move == "U")
        {
            RotateSide(cubeState.up, -90);
        }
        if (Move == "U'")
        {
            RotateSide(cubeState.up, 90);
        }
        if (Move == "U2")
        {
            RotateSide(cubeState.up, -180);
        }
        //@@@@@@@@@@@@@@@@@@@@@@
        if (Move == "D")
        {
            RotateSide(cubeState.down, -90);
        }
        if (Move == "D'")
        {
            RotateSide(cubeState.down, 90);
        }
        if (Move == "D2")
        {
            RotateSide(cubeState.down, -180);
        }
        //@@@@@@@@@@@@@@@@@@@@@@
        if (Move == "L")
        {
            RotateSide(cubeState.left, -90);
        }
        if (Move == "L'")
        {
            RotateSide(cubeState.left, 90);
        }
        if (Move == "L2")
        {
            RotateSide(cubeState.left, -180);
        }
        //@@@@@@@@@@@@@@@@@@@@@@
        if (Move == "R")
        {
            RotateSide(cubeState.right, -90);
        }
        if (Move == "R'")
        {
            RotateSide(cubeState.right, 90);
        }
        if (Move == "R2")
        {
            RotateSide(cubeState.right, -180);
        }
        //@@@@@@@@@@@@@@@@@@@@@@
        if (Move == "F")
        {
            RotateSide(cubeState.front, -90);
        }
        if (Move == "F'")
        {
            RotateSide(cubeState.front, 90);
        }
        if (Move == "F2")
        {
            RotateSide(cubeState.front, -180);
        }
        //@@@@@@@@@@@@@@@@@@@@@@
        if (Move == "B")
        {
            RotateSide(cubeState.back, -90);
        }
        if (Move == "B'")
        {
            RotateSide(cubeState.back, 90);
        }
        if (Move == "B2")
        {
            RotateSide(cubeState.back, -180);
        }
        //@@@@@@@@@@@@@@@@@@@@@@
    }