private IEnumerator FadeQuestion(float duration, QuestionContainer question, AnimationCurve alphaCurve) { float time = 0f; bool switched = false; Color titleColor = titleText.color; Color questionColor = questionText.color; while (time < duration) { time += Time.deltaTime; float value = alphaCurve.Evaluate(time / duration); questionColor.a = titleColor.a = value; titleText.color = titleColor; questionText.color = questionColor; if (!switched && time > duration / 2f) { switched = true; titleText.text = question.title; questionText.text = question.question; } yield return(null); } questionColor.a = titleColor.a = alphaCurve.Evaluate(1f); titleText.color = titleColor; questionText.color = questionColor; fadeRoutine = null; }
public void SetupAnswerMulti(QuestionContainer question, int userAnswerIndex, int categoryIndex, bool categorySwitched) { isActive = true; bool isUserAnswer = false; multiPanel.SetActive(true); singlePanel.SetActive(false); multiQuestionText.text = question.question; for (int i = 0; i < sliders.Length; i++) { //Disable Leftover Sliders if (i > question.answers.Length - 1) { sliders[i].gameObject.SetActive(false); continue; } //If needed Slider is Disabled, reenable if (!sliders[i].gameObject.activeSelf) { sliders[i].gameObject.SetActive(true); } isUserAnswer = i == userAnswerIndex ? true : false; sliders[i].ActivateBar( question.answers[i].percents[categoryIndex], question.answers[i].isRightAnswer[categoryIndex], isUserAnswer, question.answers[i].answer, categorySwitched); } }
protected void SectionRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { QuestionContainer questionContainer = (QuestionContainer)e.Item.FindControl("QuestionContainer1"); SurveyFy.API.Models.SurveySection surveySection = (SurveyFy.API.Models.SurveySection)e.Item.DataItem; //HiddenField pid = (HiddenField)e.Item.FindControl("pidHiddenField"); // HtmlControl containerdiv = (HtmlControl)e.Item.FindControl("containerdiv"); if (e.Item.ItemIndex == 0) { questionContainer.IsFirst = true; } List <SurveyFy.API.Models.Question> sectionQuestions = new List <API.Models.Question>(); foreach (SurveyFy.API.Models.Question question in questions) { foreach (SurveyFy.API.Models.SurveySectionQuestion surveySectionQuestion in question.SurveySectionQuestion) { if (surveySectionQuestion.SurveySection.Guid == surveySection.Guid) { sectionQuestions.Add(question); } } } questionContainer.Questions = sectionQuestions;//questions.Where(x => x.SurveySectionQuestion.Any(y => y.SurveySection.Guid == Guid.Parse(pid.Value))).ToList(); questionContainer.Answers = answers; questionContainer.Respondent = respondent; questionContainer.Bind(); }
public QuestionModel CreateQuestion(APIRequestModel apiRequestModel) { QuestionContainer container = new QuestionContainer { }; QuestionModel questionModel = container.FillQuestionModel(apiRequestModel); Session["questionModel"] = Utility.PrepareQuestion(questionModel); return(questionModel); }
private void Start() { m_QuestionRunning = false; m_Stopwatch = new Stopwatch(); m_QuestionContainer = XMLManager.Instance.QuestionContainer; if (!string.IsNullOrEmpty(SharedObject.GetString("planetLevel"))) { m_QuestionContainer.SetPlanet(int.Parse(SharedObject.GetString("planetLevel"))); } }
public void SetupAnswerSingle(QuestionContainer question, float userValue, float questionValue, bool categorySwitched) { isActive = true; multiPanel.SetActive(false); singlePanel.SetActive(true); singleQuestionText.text = question.question; schätzungImage.SetActive(!categorySwitched); userSlider.gameObject.SetActive(!categorySwitched); ActivateBar(userValue, questionValue, categorySwitched); }
public QuestionForm(QuestionContainer questionContainer, QuestionPrams questionPrams, int i, Random random) { InitializeComponent(); buttons = new Button[4]; buttons[0] = button1; buttons[1] = button2; buttons[2] = button3; buttons[3] = button4; QuestionContainer = questionContainer; question = questionPrams; index = i; this.random = random.Next(0, buttons.Length); }
protected override void start() { base.start(); string path = basicGameControl.name; Debug.Log(path); questions = QuestionContainer.loadQuestion(path); basicGameControl.addEvent("Reset", reset); Console.Add("Success"); Parent.SetActive(false); reset(); }
public void AddRound <T>(Round round, QuestionContainer <T> questions) where T : Question { GameRounds.Add(round); if (questions != null) { SerializedRoundQuestions.Add(JsonUtility.ToJson(questions)); } else { SerializedRoundQuestions.Add(null); } }
public static QuestionContainer LoadFromXML(string path) { TextAsset xml = Resources.Load <TextAsset>(path); XmlSerializer serializer = new XmlSerializer(typeof(QuestionContainer)); StringReader reader = new StringReader(xml.text); QuestionContainer questions = serializer.Deserialize(reader) as QuestionContainer; reader.Close(); return(questions); }
private void OnQuestionDisplay(object arg1, object arg2) { ShowQuestionPanel(); Question question = m_QuestionController.CurrentQuestion; QuestionContainer questionContainer = XMLManager.Instance.QuestionContainer; m_QuestionText.text = question.Name; m_AnswerButton1.text = questionContainer.GetAnswer1(question); m_AnswerButton2.text = questionContainer.GetAnswer2(question); m_AnswerButton3.text = questionContainer.GetAnswer3(question); #if UNITY_EDITOR m_CheatText[questionContainer.FindCorrectAnswer(question) - 1].gameObject.SetActive(true); #endif }
private void OnQuestionChanged(QuestionContainer question) { CheckForScreensaverInput(); AnimationCurve usedCurve = answerManager.isActive ? alphaTextAnswerBlendCurve : alphaTextCurve; answerManager.DeactivatePanel(); ActivateOKButton(false); answerSliderValue = 0; answerSlider.GetComponent <Slider>().value = 0f; if (fadeRoutine == null) { fadeRoutine = StartCoroutine(FadeQuestion(1f, question, usedCurve)); StartCoroutine(SetupAnswers(1, question, usedCurve)); } }
private void Start() { //string path = gameName; Debug.Log(gameName); questions = QuestionContainer.loadQuestion(gameName); Console.Add("Load Question Container"); Parent.SetActive(false); reset(); // menginstansisai game Object soal question = Parent.transform.GetChild(1).gameObject.GetComponent <Text>(); answer[0] = Parent.transform.GetChild(2).gameObject.GetComponent <Button>(); answer[0].onClick.AddListener(delegate() { this.questionAnswered(0); }); answer[1] = Parent.transform.GetChild(3).gameObject.GetComponent <Button>(); answer[1].onClick.AddListener(delegate() { this.questionAnswered(1); }); answer[2] = Parent.transform.GetChild(4).gameObject.GetComponent <Button>(); answer[2].onClick.AddListener(delegate() { this.questionAnswered(2); }); }
// Start is called before the first frame update void Start() { TextAsset questionData = Resources.Load <TextAsset>("Quiz/questions"); TextAsset factsData = Resources.Load <TextAsset>("Quiz/facts"); questions = JsonUtility.FromJson <QuestionContainer>(questionData.text); facts = JsonUtility.FromJson <FactContainer>(factsData.text); factsList = facts.text.ToArray(); questionsList = questions.Questions.ToList(); Array.Resize(ref aquiredFacts, factsList.Length); for (int i = 0; i < factsList.Length; ++i) { factsLeft.Add(i); } //Debug.Log(questionsList.Count); }
void Awake() { DontDestroyOnLoad(this); xmlPath = Application.dataPath + "/Questions.xml"; if (System.IO.File.Exists(xmlPath)) { qContainer = QuestionContainer.Load(xmlPath); qCount = qContainer.Questions.Count; nextID = qContainer.Questions [qCount - 1].qID + 1; } else { qContainer = new QuestionContainer(); qCount = 0; nextID = 1; } nextGameQuestions = new List <Question> (qContainer.Questions); }
public T[] GetQuestionsForRound <T>(int roundIndex) where T : Question { if (SerializedRoundQuestions.Count <= roundIndex) { return(null); } if (_roundQuestionsContainers == null) { _roundQuestionsContainers = new List <object>(); } Question[] questions; if (_roundQuestions.TryGetValue(roundIndex, out questions)) { return(questions as T[]); } string serializedQuestions = SerializedRoundQuestions[roundIndex]; if (serializedQuestions == null) { return(null); } QuestionContainer <T> questionContainer = JsonUtility.FromJson <QuestionContainer <T> >(serializedQuestions); while (_roundQuestionsContainers.Count <= roundIndex) { _roundQuestionsContainers.Add(null); } _roundQuestionsContainers[roundIndex] = questionContainer; _roundQuestions[roundIndex] = questionContainer != null ? questionContainer.Questions : null; return(questionContainer != null ? questionContainer.Questions : null); }
public static QuestionContainer loadQuestion(string path) { path = "file://" + Application.dataPath + "/Questions/" + path + ".xml"; Debug.Log(path); WWW file = new WWW(path); while (!file.isDone) { ; } if (!file.text.Equals("")) { XmlSerializer serializer = new XmlSerializer(typeof(QuestionContainer)); StringReader s = new StringReader(file.text); Debug.Log(file.text); return(serializer.Deserialize(s) as QuestionContainer); } else { QuestionContainer q = new QuestionContainer(); q.Save(Application.dataPath + "/" + path); return(q); } }
public void updateQManager() { qContainer = QuestionContainer.Load(xmlPath); }
private void LoadQuestions() { questionContainer = QuestionContainer.LoadFromXML("XML/Questions"); }
protected override void Awake() { base.Awake(); m_PlanetContainer = new PlanetContainer("XML", "planetInfoData.xml"); m_QuestionContainer = new QuestionContainer("XML", "questionData.xml"); }
private IEnumerator SetupAnswers(float fadeDuration, QuestionContainer question, AnimationCurve usedCurve) { float time = 0f; bool halfReached = false; bool onSecondHalfenter = true; float value = 0f; FadeObject answerSliderFade = answerSlider.GetComponent <FadeObject>(); List <FadeObject> answerFade = new List <FadeObject>(); foreach (var button in answerButtons) { answerFade.Add(button.GetComponent <FadeObject>()); } while (time < fadeDuration) { time += Time.deltaTime; value = usedCurve.Evaluate(time / fadeDuration); //Switch on Halftime if (!halfReached && time > fadeDuration / 2f) { halfReached = true; } //First Half if (!halfReached) { //Slider if (answerSlider.activeSelf) { answerSliderFade.SetOpacity(value); } else { foreach (var answer in answerFade) { answer.SetOpacity(value); } } } //Second Half else { //End First Half Deactivation if (onSecondHalfenter) { //Remove old Buttons foreach (var item in answerButtons) { Destroy(item); } answerButtons.Clear(); answerFade.Clear(); //Check for Sliders if (answerSlider.activeSelf && !question.hasSlider) { answerSliderFade.SetOpacity(0); answerSlider.SetActive(false); } //Add New Buttons Transform selectedRow; int count = question.answers.Length; for (int i = 0; i < count; i++) { selectedRow = GetRow(question.answers.Length, i); var button = Instantiate(answerButtonPrefab, selectedRow); int index = i; button.GetComponent <Button>().onClick.AddListener(delegate { OnAnswerClicked(index); }); button.GetComponentInChildren <Text>().text = question.answers[i].answer; button.GetComponent <ButtonHighlighter>().Init(); button.GetComponent <ButtonHighlighter>().SelectButton(false); button.GetComponent <FadeObject>().Init(); button.GetComponent <FadeObject>().SetOpacity(0f); answerFade.Add(button.GetComponent <FadeObject>()); answerButtons.Add(button); } onSecondHalfenter = false; } //Slider if (question.hasSlider) { if (!answerSlider.activeSelf) { answerSlider.SetActive(true); } answerSliderFade.SetOpacity(value); } //Multi Choice else { foreach (var answer in answerFade) { answer.SetOpacity(value); } } } yield return(null); } }
private void OnGUI() { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(_currentFileTitle, EditorStyles.boldLabel); if (GUILayout.Button("Reload")) { SetFile(_file); } if (GUILayout.Button("Save")) { if (_dirty) { string assetPath = AssetDatabase.GetAssetPath(_file); File.WriteAllText(assetPath, _game.Save()); AssetDatabase.Refresh(); SetFile(_file); } } } EditorGUILayout.EndHorizontal(); TextAsset newFile = EditorGUILayout.ObjectField("File", _file, typeof(TextAsset), false) as TextAsset; if (newFile != _file) { SetFile(newFile); } if (string.IsNullOrEmpty(_error) == false) { EditorGUILayout.HelpBox(_error, MessageType.Error); } if (_game == null) { return; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Delete All")) { if (EditorUtility.DisplayDialog("Delete all round", "Are you sure you want to delete all rounds?", "Delete", "Cancel")) { _game.GameRounds = new List <Round>(); _game.SerializedRoundQuestions = new List <string>(); SetGameDirty(); } } if (GUILayout.Button("Collapse All")) { for (int i = 0; i < _game.GameRounds.Count; i++) { _roundCollapsed[i] = true; Question[] questions = _game.GetQuestionsForRound <Question>(i); _questionCollapsed[i] = new Dictionary <int, bool>(); if (questions == null) { continue; } for (int j = 0; j < questions.Length; j++) { _questionCollapsed[i][j] = true; } } } if (GUILayout.Button("Open All")) { for (int i = 0; i < _game.GameRounds.Count; i++) { _roundCollapsed[i] = false; Question[] questions = _game.GetQuestionsForRound <Question>(i); _questionCollapsed[i] = new Dictionary <int, bool>(); if (questions == null) { continue; } for (int j = 0; j < questions.Length; j++) { _questionCollapsed[i][j] = false; } } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(GUI.skin.box); { _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, false, true); for (int i = 0; i < _game.GameRounds.Count; i++) { switch (_game.GetRound(i)) { case Round.ThreeSixNine: DrawThreeSixNine(i); break; case Round.Puzzle: DrawPuzzle(i); break; case Round.OpenDoor: DrawOpenDoor(i); break; case Round.Gallery: DrawGallery(i); break; case Round.CollectiveMemory: DrawCollectiveMemory(i); break; case Round.Finale: DrawFinale(i); break; case Round.Bonus: DrawBonus(i); break; case Round.Done: DrawDone(i); break; } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { _roundToAdd = (Round)EditorGUILayout.EnumPopup(_roundToAdd); if (GUILayout.Button("Add Round")) { SetGameDirty(); switch (_roundToAdd) { case Round.ThreeSixNine: ThreeSixNineQuestion[] threeSixNineQuestions = new ThreeSixNineQuestion[15]; for (int i = 0; i < threeSixNineQuestions.Length; i++) { threeSixNineQuestions[i] = new ThreeSixNineQuestion(); } QuestionContainer <ThreeSixNineQuestion> threeSixNineContainer = new QuestionContainer <ThreeSixNineQuestion>(); threeSixNineContainer.Questions = threeSixNineQuestions; _game.AddRound(_roundToAdd, threeSixNineContainer); break; case Round.Puzzle: PuzzleQuestion[] puzzleQuestions = new PuzzleQuestion[3]; for (int i = 0; i < puzzleQuestions.Length; i++) { puzzleQuestions[i] = new PuzzleQuestion(); puzzleQuestions[i].Answers = new PuzzleAnswer[3]; for (int j = 0; j < puzzleQuestions[i].Answers.Length; j++) { puzzleQuestions[i].Answers[j] = new PuzzleAnswer(); puzzleQuestions[i].Answers[j].Words = new[] { "", "", "", "" }; } } QuestionContainer <PuzzleQuestion> puzzleContainer = new QuestionContainer <PuzzleQuestion>(); puzzleContainer.Questions = puzzleQuestions; _game.AddRound(_roundToAdd, puzzleContainer); break; case Round.OpenDoor: OpenDoorQuestion[] openDoorQuestions = new OpenDoorQuestion[3]; for (int i = 0; i < openDoorQuestions.Length; i++) { openDoorQuestions[i] = new OpenDoorQuestion(); openDoorQuestions[i].Answers = new OpenDoorAnswer[4]; for (int j = 0; j < openDoorQuestions[i].Answers.Length; j++) { openDoorQuestions[i].Answers[j] = new OpenDoorAnswer(); } } QuestionContainer <OpenDoorQuestion> openDoorContainer = new QuestionContainer <OpenDoorQuestion>(); openDoorContainer.Questions = openDoorQuestions; _game.AddRound(_roundToAdd, openDoorContainer); break; case Round.Gallery: GalleryQuestion[] galleryQuestions = new GalleryQuestion[3]; for (int i = 0; i < galleryQuestions.Length; i++) { galleryQuestions[i] = new GalleryQuestion(); galleryQuestions[i].Answers = new GalleryAnswer[10]; for (int j = 0; j < galleryQuestions[i].Answers.Length; j++) { galleryQuestions[i].Answers[j] = new GalleryAnswer(); } } QuestionContainer <GalleryQuestion> galleryContainer = new QuestionContainer <GalleryQuestion>(); galleryContainer.Questions = galleryQuestions; _game.AddRound(_roundToAdd, galleryContainer); break; case Round.Bonus: _game.AddRound <Question>(_roundToAdd, null); break; case Round.Done: _game.AddRound <Question>(_roundToAdd, null); break; case Round.CollectiveMemory: CollectiveMemoryQuestion[] collectiveMemoryQuestions = new CollectiveMemoryQuestion[3]; for (int i = 0; i < collectiveMemoryQuestions.Length; i++) { collectiveMemoryQuestions[i] = new CollectiveMemoryQuestion(); collectiveMemoryQuestions[i].Answers = new string[5]; collectiveMemoryQuestions[i].TimeRewards = new int[5]; for (int j = 0; j < collectiveMemoryQuestions[i].Answers.Length; j++) { collectiveMemoryQuestions[i].Answers[j] = "Antwoord " + (i + 1); collectiveMemoryQuestions[i].TimeRewards[j] = 0; } } QuestionContainer <CollectiveMemoryQuestion> collectiveMemoryContainer = new QuestionContainer <CollectiveMemoryQuestion>(); collectiveMemoryContainer.Questions = collectiveMemoryQuestions; _game.AddRound(_roundToAdd, collectiveMemoryContainer); break; case Round.Finale: FinaleQuestion[] finaleQuestions = new FinaleQuestion[12]; for (int i = 0; i < finaleQuestions.Length; i++) { finaleQuestions[i] = new FinaleQuestion(); finaleQuestions[i].Answers = new FinaleAnswer[5]; for (int j = 0; j < finaleQuestions[i].Answers.Length; j++) { finaleQuestions[i].Answers[j] = new FinaleAnswer(); } } QuestionContainer <FinaleQuestion> finaleContainer = new QuestionContainer <FinaleQuestion>(); finaleContainer.Questions = finaleQuestions; _game.AddRound(_roundToAdd, finaleContainer); break; } } } EditorGUILayout.EndHorizontal(); if (_roundIndexToRemove != -1) { _game.RemoveRound(_roundIndexToRemove); SetGameDirty(); _roundIndexToRemove = -1; } }