Exemplo n.º 1
0
    public void detectRetate(List <GameObject> pieces, List <GameObject> planes)
    {
        //detect if player start playing
        if (startbtn)
        {
            startplaying = true;
            StartTime    = Time.timeSinceLevelLoad;
            startbtn     = false;
        }

        if (!canRetat || !canShuffle)
        {
            return;
        }

        if (UpVerticalPieces.Exists(x => x == pieces[0]) && UpVerticalPieces.Exists(x => x == pieces[1]))
        {
            StartCoroutine(retation(UpVerticalPieces, new Vector3(0, 0, 1 * detectLeftMiddleRightSign(pieces))));
        }

        else if (UpHorizontalPieces.Exists(x => x == pieces[0]) && UpHorizontalPieces.Exists(x => x == pieces[1]))
        {
            StartCoroutine(retation(UpHorizontalPieces, new Vector3(1 * detectFrontMiddleBackSign(pieces), 0, 0)));
        }
        else if (FrontHorizontalPieces.Exists(x => x == pieces[0]) && FrontHorizontalPieces.Exists(x => x == pieces[1]))
        {
            StartCoroutine(retation(FrontHorizontalPieces, new Vector3(0, 1 * detectUpMiddleDownSign(pieces), 0)));
        }

        else if (detectSide(planes, new Vector3(1, 0, 0), new Vector3(0, 0, 1), UpPieces))
        {
            StartCoroutine(retation(UpPieces, new Vector3(0, 1 * detectUpMiddleDownSign(pieces), 0)));
        }

        else if (detectSide(planes, new Vector3(1, 0, 0), new Vector3(0, 0, 1), DownPieces))
        {
            StartCoroutine(retation(DownPieces, new Vector3(0, 1 * detectUpMiddleDownSign(pieces), 0)));
        }

        else if (detectSide(planes, new Vector3(0, 0, 1), new Vector3(0, 1, 0), FrontPieces))
        {
            StartCoroutine(retation(FrontPieces, new Vector3(1 * detectFrontMiddleBackSign(pieces), 0, 0)));
        }

        else if (detectSide(planes, new Vector3(0, 0, 1), new Vector3(0, 1, 0), BackPieces))
        {
            StartCoroutine(retation(BackPieces, new Vector3(1 * detectFrontMiddleBackSign(pieces), 0, 0)));
        }

        else if (detectSide(planes, new Vector3(1, 0, 0), new Vector3(0, 1, 0), LeftPieces))
        {
            StartCoroutine(retation(LeftPieces, new Vector3(0, 0, 1 * detectLeftMiddleRightSign(pieces))));
        }

        else if (detectSide(planes, new Vector3(1, 0, 0), new Vector3(0, 1, 0), RightPieces))
        {
            StartCoroutine(retation(RightPieces, new Vector3(0, 0, 1 * detectLeftMiddleRightSign(pieces))));
        }
    }
Exemplo n.º 2
0
    public void DetectRotate(List <GameObject> pieces, List <GameObject> planes)
    {
        if (!canRotate || !canShuffle)
        {
            return;
        }

        if (UpVerticalPieces.Exists(x => x == pieces[0]) &&
            UpVerticalPieces.Exists(x => x == pieces[1]))
        {
            StartCoroutine(Rotate(UpVerticalPieces, new Vector3(0, 0, 1 * DetectLeftMiddleRightSign(pieces))));
        }

        else if (UpHorizontalPieces.Exists(x => x == pieces[0]) &&
                 UpHorizontalPieces.Exists(x => x == pieces[1]))
        {
            StartCoroutine(Rotate(UpHorizontalPieces, new Vector3(1 * DetectFrontMiddleBackSign(pieces), 0, 0)));
        }

        else if (FrontHorizontalPieces.Exists(x => x == pieces[0]) &&
                 FrontHorizontalPieces.Exists(x => x == pieces[1]))
        {
            StartCoroutine(Rotate(FrontHorizontalPieces, new Vector3(0, 1 * DetectUpMiddleDownSign(pieces), 0)));
        }

        else if (DetectSide(planes, new Vector3(1, 0, 0), new Vector3(0, 0, 1), UpPieces))
        {
            StartCoroutine(Rotate(UpPieces, new Vector3(0, 1 * DetectUpMiddleDownSign(pieces), 0)));
        }

        else if (DetectSide(planes, new Vector3(1, 0, 0), new Vector3(0, 0, 1), DownPieces))
        {
            StartCoroutine(Rotate(DownPieces, new Vector3(0, 1 * DetectUpMiddleDownSign(pieces), 0)));
        }

        else if (DetectSide(planes, new Vector3(0, 0, 1), new Vector3(0, 1, 0), FrontPieces))
        {
            StartCoroutine(Rotate(FrontPieces, new Vector3(1 * DetectFrontMiddleBackSign(pieces), 0, 0)));
        }

        else if (DetectSide(planes, new Vector3(0, 0, 1), new Vector3(0, 1, 0), BackPieces))
        {
            StartCoroutine(Rotate(BackPieces, new Vector3(1 * DetectFrontMiddleBackSign(pieces), 0, 0)));
        }

        else if (DetectSide(planes, new Vector3(1, 0, 0), new Vector3(0, 1, 0), LeftPieces))
        {
            StartCoroutine(Rotate(LeftPieces, new Vector3(0, 0, 1 * DetectLeftMiddleRightSign(pieces))));
        }

        else if (DetectSide(planes, new Vector3(1, 0, 0), new Vector3(0, 1, 0), RightPieces))
        {
            StartCoroutine(Rotate(RightPieces, new Vector3(0, 0, 1 * DetectLeftMiddleRightSign(pieces))));
        }
    }