Example #1
0
 public void AddORemoveAnswer(bool isAdd)
 {
     if (isAdd && question.answers < 4)
     {
         figurePanel.InstantiateAnswer(this.gameObject.transform.parent);
         question.answers++;
     }
     else if (!isAdd && question.answers > 1)
     {
         Destroy(this.gameObject);
         question.answers--;
     }
     Invoke(nameof(AnswerListHandler.resetQnA), 0.02f);
 }
Example #2
0
    /// <summary>
    /// Initializes a figures and then its questions and answers
    /// </summary>
    /// <param name="figure">Figure to instantiate</param>
    /// <param name="QuestionsAndAnswers">Dictionary of questions and answers to instantiate</param>
    private void InitializeScenarioFigure(ScenarioFigure figure, Dictionary <ScenarioQuestion, List <ScenarioAnswer> > QuestionsAndAnswers)
    {
        GameObject  newPanel = AddFigure(figure.Figure_Id.ToString(), figure);
        FigurePanel fp       = newPanel.GetComponent <FigurePanel>();

        foreach (var QnA in QuestionsAndAnswers)
        {
            GameObject questionTemp = fp.InstantiateQuestion(QnA.Key.Question_Text, QnA.Key.Scenario_Figure_Id, QnA.Key.Id);
            Dictionary <GameObject, ScenarioAnswer> answers = new Dictionary <GameObject, ScenarioAnswer>();
            foreach (var answer in QnA.Value)
            {
                answers.Add(fp.InstantiateAnswer(questionTemp.transform, answer.Answer_Text, answer.Scenario_Question_Id, answer.Id), answer);
            }
            foreach (var answerGOPair in answers)
            {
                if (answerGOPair.Value.Correct_Answer == 1)
                {
                    answerGOPair.Key.GetComponentInChildren <Toggle>().isOn = true;
                }
            }
        }
        figurePanelRef.resetPanelsFunc();
    }
Example #3
0
 public void AddAnswer(Transform parentQuestion)
 {
     figurePanelRef.InstantiateAnswer(parentQuestion);
 }