Пример #1
0
    public void PokazPlaszczyznyObrotu()
    {
        foreach (GameObject go in plaszczyznyObrotuWszystkie)
        {
            go.GetComponent <Image>().enabled = false;
        }

        pokazujPlaszczyznyObrotu = tglPokazPlaszczyzny1.GetComponent <Toggle>().isOn;
        Debug.Log(tglPokazPlaszczyzny1.GetComponent <Toggle>().isOn.ToString());
        R1plaszczObrotu.GetComponent <Image>().enabled = pokazujPlaszczyznyObrotu;
        R2plaszczObrotu.GetComponent <Image>().enabled = pokazujPlaszczyznyObrotu;
        R3plaszczObrotu.GetComponent <Image>().enabled = pokazujPlaszczyznyObrotu;
    }
Пример #2
0
    IEnumerator obracaj()
    {
        AktualizujKombinacjeObrotow2();
        if (playstate == 1)
        { //obrot R1
            koniec = false;
            btnPause.GetComponent <Image>().enabled = true;
            btnPlay.GetComponent <Image>().enabled  = false;
            R1Arc.GetComponent <Image>().enabled    = true;
            R1txtAngle.SetActive(true);
            foreach (GameObject go in goOpisyOsiR1)
            {
                go.SetActive(true);
            }
            R1txtAngle.GetComponent <TextMesh>().text      = "";
            R1plaszczObrotu.GetComponent <Image>().enabled = pokazujPlaszczyznyObrotu;
            Vector3[] osieObrotow = { -transform.right, -transform.forward, -transform.up };
            int       idx         = goWyborR1.GetComponent <Dropdown>().value;
            osR1 = osieObrotow[idx];

            if (Math.Abs(i) < Math.Abs(fi))
            {
                dangle = fi * myRotationSpeed * Time.deltaTime * 0.01f;
                Debug.Log(dangle.ToString());
                transform.RotateAround(transform.position, osR1, dangle);
                goUklObracanycienR1.transform.RotateAround(transform.position, osR1, dangle);
                goUklObracanycienR2.transform.RotateAround(transform.position, osR1, dangle);
                i += dangle;
                R1Arc.GetComponent <Image>().fillAmount   = Math.Abs(i) / 360f;
                R1txtAngle.GetComponent <TextMesh>().text = Math.Round(i, 1).ToString();
            }
            else
            {
                transform.RotateAround(transform.position, osR1, -(i - fi));
                goUklObracanycienR1.transform.RotateAround(transform.position, osR1, -(i - fi));
                goUklObracanycienR2.transform.RotateAround(transform.position, osR1, -(i - fi));
                R1Arc.GetComponent <Image>().fillAmount   = Math.Abs(fi) / 360f;
                R1txtAngle.GetComponent <TextMesh>().text = Math.Round(fi, 1).ToString();
                // Debug.Log((i-(i - fi)).ToString());
                playstate = 2;
                i         = 0;
            }
        }

        if (playstate == 2)
        {
            yield return(new WaitForSeconds(czasPauzy));

            StopAllCoroutines();
            playstate = 3;
        }



        if (playstate == 3)   //obrot R2
        {
            R2Arc.GetComponent <Image>().enabled = true;
            R2txtAngle.SetActive(true);
            foreach (GameObject go in goOpisyOsiR2)
            {
                go.SetActive(true);
            }
            R2txtAngle.GetComponent <TextMesh>().text      = "";
            R2plaszczObrotu.GetComponent <Image>().enabled = pokazujPlaszczyznyObrotu;
            Vector3[] osieObrotow = { -transform.right, -transform.forward, -transform.up };
            int       idx         = goWyborR2.GetComponent <Dropdown>().value;
            osR2 = osieObrotow[idx];
            if (Math.Abs(i) < Math.Abs(theta))
            {
                dangle = theta * myRotationSpeed * Time.deltaTime * 0.01f;
                transform.RotateAround(transform.position, osR2, dangle);
                goUklObracanycienR2.transform.RotateAround(transform.position, osR2, dangle);
                i += dangle;
                R2Arc.GetComponent <Image>().fillAmount   = Math.Abs(i) / 360f;
                R2txtAngle.GetComponent <TextMesh>().text = Math.Round(i, 1).ToString();
            }
            else
            {
                transform.RotateAround(transform.position, osR2, -(i - theta));
                goUklObracanycienR2.transform.RotateAround(transform.position, osR2, -(i - theta));
                R2Arc.GetComponent <Image>().fillAmount   = Math.Abs(theta) / 360f;
                R2txtAngle.GetComponent <TextMesh>().text = Math.Round(theta, 1).ToString();
                // Debug.Log((i-(i - theta)).ToString());
                i         = 0;
                playstate = 4;
            }
        }

        if (playstate == 4)
        {
            yield return(new WaitForSeconds(czasPauzy));

            StopAllCoroutines();
            playstate = 5;
        }


        if (playstate == 5)    //obrot Z2
        {
            R3Arc.GetComponent <Image>().enabled = true;
            R3txtAngle.SetActive(true);
            foreach (GameObject go in goOpisyOsiR3)
            {
                go.SetActive(true);
            }
            R3txtAngle.GetComponent <TextMesh>().text      = "";
            R3plaszczObrotu.GetComponent <Image>().enabled = pokazujPlaszczyznyObrotu;
            Vector3[] osieObrotow = { -transform.right, -transform.forward, -transform.up };
            int       idx         = goWyborR3.GetComponent <Dropdown>().value;
            osR3 = osieObrotow[idx];
            if (Math.Abs(i) < Math.Abs(psi))
            {
                dangle = psi * myRotationSpeed * Time.deltaTime * 0.01f;
                transform.RotateAround(transform.position, osR3, dangle);
                i += dangle;
                R3Arc.GetComponent <Image>().fillAmount   = Math.Abs(i) / 360f;
                R3txtAngle.GetComponent <TextMesh>().text = Math.Round(i, 1).ToString();
                //yield return new WaitForSeconds(1);
                //yield return null;
            }
            else
            {
                transform.RotateAround(transform.position, osR3, -(i - psi));
                R3Arc.GetComponent <Image>().fillAmount   = Math.Abs(psi) / 360f;
                R3txtAngle.GetComponent <TextMesh>().text = Math.Round(psi, 1).ToString();
                playstate = 0;
                // Debug.Log((i-(i - psi)).ToString());
                btnPlay.GetComponent <Image>().enabled  = true;
                btnPause.GetComponent <Image>().enabled = false;
                i      = 0;
                koniec = true;
            }
        }
    }