예제 #1
0
    public override void buildQuestion(GameObject answersPanelLeft, GameObject answersPanelRight, Quiz_Handler quizHandler_)
    {
        answersPanelLeftUsed  = answersPanelLeft;
        answersPanelRightUsed = answersPanelRight;

        quizHandler = quizHandler_;

        List <string> possibilities = new List <string> ();

        foreach (string orderElement in correctOrder)
        {
            possibilities.Add(orderElement);
        }

        GameObject circle = Instantiate(quizHandler.circlePrefab) as GameObject;

        circle.transform.SetParent(answersPanelRight.transform, false);

        while (possibilities.Count > 0)
        {
            string answer = possibilities [UnityEngine.Random.Range(0, possibilities.Count)];
            possibilities.Remove(answer);
            GameObject newSlot = Instantiate(quizHandler.slotPanelPrefab) as GameObject;
            newSlot.transform.SetParent(answersPanelLeft.transform, false);

            GameObject newAnswer = Instantiate(quizHandler.orderButtonPrefab) as GameObject;

            newAnswer.GetComponent <DragHandler> ().canvas            = quizHandler.canvas;
            newAnswer.GetComponent <DragHandler> ().questionToNotifiy = this;
            newAnswer.GetComponentInChildren <Text> ().text           = answer;
            newAnswer.transform.SetParent(newSlot.transform, false);
        }
    }
예제 #2
0
    public override void buildQuestion(GameObject answersPanelLeft, GameObject answersPanelRight, Quiz_Handler quizHandler)
    {
        quizHandler.furtherButton.GetComponent <Button>().interactable = false;

        answersPanelLeftUsed  = answersPanelLeft;
        answersPanelRightUsed = answersPanelRight;

        List <string> possibilities = new List <string> ();

        foreach (string wrongAnswer in wrongAnswers)
        {
            possibilities.Add(wrongAnswer);
        }
        possibilities.Add(rightAnswer);

        int startCountAnswers = possibilities.Count;

        GameObject answersPanel = answersPanelLeft;

        while (possibilities.Count > 0)
        {
            if (possibilities.Count <= startCountAnswers / 2)
            {
                answersPanel = answersPanelRight;
            }

            string answer = possibilities [UnityEngine.Random.Range(0, possibilities.Count)];
            possibilities.Remove(answer);
            GameObject newAnswer = Instantiate(quizHandler.choiceTogglePrefab) as GameObject;
            newAnswer.GetComponent <Toggle> ().group = answersPanelLeft.GetComponent <ToggleGroup>();
            newAnswer.GetComponent <Toggle> ().onValueChanged.AddListener((isSelected) => {
                if (!isSelected)
                {
                    return;
                }
                quizHandler.setEvaluteButtonEnabled(true);
            });

            newAnswer.GetComponentInChildren <Text> ().text = answer;
            newAnswer.transform.SetParent(answersPanel.transform, false);
            newAnswer.transform.localScale = Vector3.one;
        }
    }
예제 #3
0
 public abstract void buildQuestion(GameObject answersPanelLeft, GameObject answersPanelRight, Quiz_Handler quizHandler);