private List<ScenarioAnswer> GetAnswers(ScenarioQuestion question) { List<ScenarioAnswer> answers = new List<ScenarioAnswer>(); foreach (var QuestionsAndAnswers in DatabaseHandler.FiguresWithQuestionsAndAnswers[currentFigure]) { if (QuestionsAndAnswers.Key == currentQuestion) { foreach (var answer in QuestionsAndAnswers.Value) { answers.Add(answer); } } } return answers; }
public void InitializePlayUI() { if (totalQuestions == null) { totalQuestions = GetTotalQuestions(); currentFigure = DatabaseHandler.FiguresWithQuestionsAndAnswers.Keys.First(); } questionPanel.SetActive(true); currentQuestion = DatabaseHandler.FiguresWithQuestionsAndAnswers[currentFigure].Keys.First(); currentAnswers = GetAnswers(currentQuestion); ARInteraction.AREnabled = false; translator.SetQuestionText(currentQuestion.Question_Text); translator.ShowAnswers(currentAnswers.Count, currentAnswers); }
private void NextQuestion() { ScenarioQuestion nextQuestion = null; try { nextQuestion = DatabaseHandler.FiguresWithQuestionsAndAnswers[currentFigure].Keys.SkipWhile(k => k != currentQuestion).Skip(1).First(); Debug.Log(currentFigure.Id); } catch { } if (nextQuestion != null) { currentQuestion = nextQuestion; currentAnswers = GetAnswers(currentQuestion); translator.SetQuestionText(currentQuestion.Question_Text); translator.ShowAnswers(currentAnswers.Count, currentAnswers); } else { try { currentFigure = DatabaseHandler.FiguresWithQuestionsAndAnswers.Keys.SkipWhile(k => k != currentFigure).Skip(1).First(); } catch { currentFigure = null; } if (currentFigure == null) { ShowResults(); } else { panelHandler.OpenPlayPopUp(); Destroy(GameObject.FindGameObjectWithTag("ARContent")); arTap.contentToPlace = GetNextFigureById(currentFigure.Figure_Id); arTap.isPlaced = false; ARInteraction.AREnabled = true; questionPanel.SetActive(false); currentQuestion = DatabaseHandler.FiguresWithQuestionsAndAnswers[currentFigure].Keys.First(); } } }
/// <summary> /// Load an existing scenario /// </summary> /// <param name="hiddenScenarioId">ID of the scenario to load (found in each scenario list item prefab)</param> public void LoadScenarioDetails(Text hiddenScenarioId) { Clear(); hiddenScenarioIdField.text = hiddenScenarioId.text; if (hiddenScenarioId.text == "" || hiddenScenarioId == null) { scenarioAvailableToggle.isOn = true; scenarioNameInputField.text = ""; scenarioStoryTypeDropDown.value = (int)StoryType.Scavenger; } else { Scenario temp = null; foreach (Scenario s in Scenario.Scenarios) { if (s.Id == int.Parse(hiddenScenarioIdField.text)) { temp = s; } } if (temp != null) { if (temp.Available == 0) { scenarioAvailableToggle.isOn = false; } scenarioNameInputField.text = temp.Name; scenarioStoryTypeDropDown.value = (int)temp.StoryType; DBConnector.GetScenarioFigureData((callback) => { foreach (object figure in callback) { Dictionary <ScenarioQuestion, List <ScenarioAnswer> > QuestionsAndAnswers = new Dictionary <ScenarioQuestion, List <ScenarioAnswer> >(); PropertyInfo[] info = figure.GetType().GetProperties(); ScenarioFigure tempFigure = (ScenarioFigure)figure; DBConnector.GetQuestionData((questionCallback) => { foreach (object question in questionCallback) { ScenarioQuestion tempQuestion = (ScenarioQuestion)question; DBConnector.GetAnswerData((answerCallback) => { List <ScenarioAnswer> answers = new List <ScenarioAnswer>(); foreach (object answer in answerCallback) { ScenarioAnswer tempAnswer = (ScenarioAnswer)answer; answers.Add(tempAnswer); } QuestionsAndAnswers.Add(tempQuestion, answers); InitializeScenarioFigure(tempFigure, QuestionsAndAnswers); }, scenario_question_id: tempQuestion.Id); } figuresWithQnA.Add(tempFigure, QuestionsAndAnswers); }, scenario_figure_id: tempFigure.Id); } }, scenario_id: int.Parse(hiddenScenarioId.text)); } else { Debug.LogError("Something went wrong while trying to load scenario details of scenario id: " + hiddenScenarioIdField.text); } } }