Exemple #1
0
    public void Close_QuestionAnswer()
    {
        SoundControl.PlaySFX(GlobalData.SFX_Paths[0], false, true, true);

        this.transform.Find("btn_back").gameObject.SetActive(true);
        QuestionAnswerWindow.SetActive(false);
        QuestionContent.SetActive(true);
    }
Exemple #2
0
    public void opendifficulty(int difficulty)
    {
        SoundControl.PlaySFX(GlobalData.SFX_Paths[0], false, true, true);


        foreach (Transform child in QuestionContent.transform)
        {
            GameObject.Destroy(child.gameObject);
        }
        QuizDificulty.SetActive(false);
        QuestionContent.transform.parent.gameObject.SetActive(true);
        this.transform.Find("btn_back").gameObject.SetActive(true);

        int   curr_numofquestions = 0;
        float h = 0, yvalue = 0;

        for (int i = 0; i < GlobalData.SAVEDQUIZQUESTIONS[difficulty].Count; i++)
        {
            if (GlobalData.SAVEDQUIZQUESTIONS[difficulty][i].difficulty == difficulty)
            {
                GameObject QuestionPrefab = (GameObject)Instantiate(Resources.Load("Prefabs/UI/GlossaryQuestion"));
                QuestionPrefab.transform.parent = QuestionContent.transform;

                //Joao2409
                float height = Screen.height;
                h = 120 * height / 640;


                yvalue = -60 * curr_numofquestions + Screen.height / 640 - h * curr_numofquestions;
                //Joao2409

                QuestionPrefab.transform.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, yvalue, 0);
                QuestionPrefab.transform.GetComponent <RectTransform>().sizeDelta        = new Vector2(0, 0);

                QuestionPrefab.transform.transform.Find("Questionnumber").GetComponent <Text>().text = ((curr_numofquestions + 1) + ".").ToString();
                QuestionPrefab.transform.transform.Find("Question").GetComponent <Text>().text       = GlobalData.SAVEDQUIZQUESTIONS[difficulty][i].Q.ToString();

                QuestionPrefab.name = i.ToString();

                QuestionPrefab.GetComponent <Button>().onClick.RemoveAllListeners();
                QuestionPrefab.GetComponent <Button>().onClick.AddListener(() => {
                    //code
                    SoundControl.PlaySFX(GlobalData.SFX_Paths[0], false, true, true);

                    QuestionAnswerWindow.SetActive(true);
                    this.transform.Find("btn_back").gameObject.SetActive(false);
                    QuestionAnswerWindow.transform.Find("Question").GetComponent <Text>().text = "Q. " + GlobalData.SAVEDQUIZQUESTIONS[difficulty][int.Parse(QuestionPrefab.gameObject.name)].Q.ToString();
                    QuestionAnswerWindow.transform.Find("Answer").GetComponent <Text>().text   = "R. " + GlobalData.SAVEDQUIZQUESTIONS[difficulty][int.Parse(QuestionPrefab.gameObject.name)].RA.ToString();
                    QuestionContent.SetActive(false);
                });
                maxindex = yvalue + h;
                curr_numofquestions++;
            }
        }
    }