Ejemplo n.º 1
0
    public void CreateTest(OCTestItem t)
    {
        float fullScreenHeight = Camera.main.orthographicSize * 2;
        float fullScreenWidth  = fullScreenHeight * 16 / 9; // basically height * screen aspect ratio

        //this will give us the world unit width of the screen (doubled it to account for the negative side)
        //divide the screen width by the amount of objects in the array to get offset from left side
        //changed this to fix something, make sure it didn't break everything else
        float offsetX = fullScreenWidth / (t.LetterButtons.Length + 2);

        float offsetY = fullScreenHeight / 2;

        float leftScreenPos = -fullScreenWidth / 2 + offsetX / 2;
        float topScreenPos  = fullScreenHeight / 2 - offsetY / 2;

        GameObject o;

        if (!GameObject.Find("origin"))
        {
            o = new GameObject("origin");
            o.transform.position = new Vector3(0, -offsetY / 2, 0);
            TextMesh tm = o.AddComponent <TextMesh>();
            tm.alignment           = TextAlignment.Center;
            tm.anchor              = TextAnchor.MiddleCenter;
            tm.fontSize            = 100;
            tm.color               = Color.black;
            o.transform.localScale = Vector3.one * fullScreenHeight / 6f;

            o = new GameObject("topOrigin");
            o.transform.position = new Vector3(0, offsetY / 2, 0);
            tm                     = o.AddComponent <TextMesh>();
            tm.alignment           = TextAlignment.Center;
            tm.anchor              = TextAnchor.MiddleCenter;
            tm.fontSize            = 100;
            tm.color               = Color.black;
            o.transform.localScale = Vector3.one * fullScreenHeight / 6f;
            //o.layer = LayerMask.NameToLayer("fade");

            o = new GameObject("midOrigin");
            o.transform.position = new Vector3(0, 0, 0);
            tm                     = o.AddComponent <TextMesh>();
            tm.alignment           = TextAlignment.Center;
            tm.anchor              = TextAnchor.MiddleCenter;
            tm.fontSize            = 100;
            tm.color               = Color.black;
            o.transform.localScale = Vector3.one * fullScreenHeight / 6f;
            //o.layer = LayerMask.NameToLayer("fade");

            o = new GameObject("audio");
            o.transform.position = new Vector3((-fullScreenWidth / 16) * 5, -offsetY / 2, 0);

            o = new GameObject("arrow");
            o.transform.position = new Vector3((fullScreenWidth / 16) * 5, -offsetY / 2, 0);
        }
        for (int i = 0; i < t.LetterButtons.Length; i++)
        {
            offsetX = fullScreenWidth / 10;
            float dist = fullScreenHeight / 3f;
            o       = Instantiate(t.LetterButtons[i], new Vector3((i - 2) * dist + dist / 2, offsetY / 3, 0), new Quaternion());
            o.layer = LayerMask.NameToLayer("fadeOut");
            if (t.isCorrect[i])
            {
                o.name = "correct clone";
            }
            else
            {
                o.name = "incorrect clone";
            }
            GameObject     child = new GameObject("image");
            SpriteRenderer s     = child.AddComponent <SpriteRenderer>();
            s.sortingOrder                                  = 0;
            s.sprite                                        = t.wordPictures[i];
            child.transform.parent                          = o.transform;
            child.transform.localPosition                   = new Vector3(0, 0, 0);
            o.GetComponent <ClickCardOC>().isCorrect        = t.isCorrect[i];
            o.GetComponent <ClickCardOC>().responsePosition = i + 1;
            o.GetComponent <ClickCardOC>().responseName     = t.wordPictures[i].name;
            o.transform.localScale                          = Vector3.one * fullScreenHeight / 10f * 3f;
            //GameObject.Destroy(o.transform.GetChild(0).gameObject);
        }

        //This is to make sure we are only printing what we need
        //Will be used for all examples so event system will handle printing
        //if (!t.skipPrint)
        //    //may need to be 0, check if resetTimer
        //    OCOutputHandler.StartTimer(0);
    }
Ejemplo n.º 2
0
 void setNextTestItem()
 {
     base.backEndItem = base.testItemBackEnd[base.currentTestNumber];
     frontEndItem     = testItemFrontEnd[base.currentTestNumber];
     base.nextTest    = false;
 }