Ejemplo n.º 1
0
    public void Solve()
    {
        if (RCP.RC.isSolved())
        {
            Debug.Log("isSolved");
        }
        else
        {
            RubiksCube RC_target   = new RubiksCube();
            RubiksCube RC_original = RCP.RC.cloneCube();
            s = new Solutionn(RC_target, RC_original, true);

            string sol = null;
            sol = s.A();

            RubiksCube solCube = new RubiksCube();
            solCube.RunCustomSequence(sol);
            coroutine = RCP.animateCustomSequence(sol);
            StartCoroutine(coroutine);

            ////To set the UI label with the solution.
            txtTurnRecord.text = sol;
            ////To know the total number of moves and update the UI label
            txtNumMoves.text = solCube.TurnRecordTokenCount() + " Moves";


            Debug.Log("Cantidad Movimientos: " + solCube.TurnRecordTokenCount());
        }
    }
Ejemplo n.º 2
0
    public void Solve()
    {
        Debug.Log("Standard Solve");

        if (coroutine != null)
        {
            StopCoroutine(coroutine);
        }

        RubiksCube RC = RCP.RC.cloneCube();

        S = new Solver(RC);

        string solution = S.Solution();

        RubiksCube solCube = new RubiksCube();

        solCube.RunCustomSequence(solution);
        coroutine = RCP.animateCustomSequence(solution);
        StartCoroutine(coroutine);
        txtTurnRecord.text = solution;
        txtNumMoves.text   = solCube.TurnRecordTokenCount() + " Moves";
        Debug.Log(solution);
        Debug.Log(solCube.TurnRecordTokenCount() + " Moves");
    }
Ejemplo n.º 3
0
    private void HandleInput()
    {
        //if (Input.GetKeyDown(KeyCode.S))
        //{
        //    ScrambleCube();
        //    SolutionString = Solve();
        //    SolutionArr = ParseMoves(SolutionString);
        //    Debug.Log(SolutionArr.Count);
        //    nextMove = 0;
        //    RCP.RefreshPanels();
        //}

        if (Input.GetKeyDown(KeyCode.N))
        {
            if (nextMove < SolutionArr.Count)
            {
                if (!RCP.Animating)
                {
                    Debug.Log(nextMove);
                    coroutine = StartCoroutine(RCP.animateCustomSequence(SolutionArr[nextMove++]));
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.B))
        {
            if (nextMove > 0)
            {
                if (!RCP.Animating)
                {
                    StartCoroutine(RCP.animateCustomSequence(invertMove(SolutionArr[--nextMove])));
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (!RCP.Animating)
            {
                StartCoroutine(RCP.animateCustomSequence(SubstringFromList(SolutionArr, false, nextMove, SolutionArr.Count)));
                nextMove = SolutionArr.Count;
            }
        }

        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            if (!RCP.Animating)
            {
                StartCoroutine(RCP.animateCustomSequence(SubstringFromList(SolutionArr, true, 0, nextMove - 1)));
                nextMove = 0;
            }
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            //if (socket_connected)
            //socket.Send("Reset");
            RCP.ResetView();
            RCP.RC.RunCustomSequence(SubstringFromList(SolutionArr, true, 0));
            nextMove = 0;
            RCP.RefreshPanels();
        }

        //Move Camera

        m_currentMousePos = Input.mousePosition;

        if (Input.GetMouseButton(0))
        {
            m_delta    = m_currentMousePos - m_lastMousePos;
            m_delta.x /= Screen.currentResolution.width;
            m_delta.y /= Screen.currentResolution.height;
        }
        else
        {
            m_delta = Vector2.zero;
        }


        m_lastMousePos = m_currentMousePos;

        m_camera.RotateBy(m_delta.y, m_delta.x);
        m_camera.ZoomBy(-1 * Input.GetAxis("Mouse ScrollWheel"));
    }