public override GameState OnStart(QuizMain game_instance) { Data game_data = Data.GetInstance(); QuizConfig config = game_data.GetConfig(); Debug.Log("config question lists " + config.QuestionLists.Count); foreach (QuestionListConfig qlist in config.QuestionLists) { game_instance.AddToList(qlist.ListSize, qlist.ListDifficulty, qlist.ListSubjects.ToArray(), qlist.Uniform); //game_data.ReportSubjects( } foreach (int special_index in config.SpecialQuestions) { game_instance.SetSpecial(special_index); } game_instance.SetButtonEnable(Action.Next, false); game_data.MaxProgress = game_instance.QuestionListSize; return(null); }
// config the match data before starting a match public void SetConfig(QuizConfig c) { config = c; //_max_progress = config.GetTotalQuestions(); question_time_limit = config.TimeLimit; tokens = config.Tokens; show_subject_score = c.ShowSubjectScore; //DebugSubjects (); // foreach (QuestionListConfig qlistconfig in c.QuestionLists){ // AddSubjects(qlistconfig.ListSubjects.ToArray()); // } }
public override void OnInspectorGUI() { //DrawDefaultInspector(); Target = (ConfigButton)target; QuizConfig config = Target.config; config.ShowSubjectScore = EditorGUILayout.Toggle("Show subject score", config.ShowSubjectScore); //int i = 0; for (int i = 0; i < config.QuestionLists.Count; i++) { EditorGUILayout.BeginHorizontal(); { fold[i] = EditorGUILayout.Foldout(fold[i], "Question List " + (i + 1).ToString()); if (GUILayout.Button("x")) { config.QuestionLists.RemoveAt(i); fold.RemoveAt(i); break; } } EditorGUILayout.EndHorizontal(); if (fold[i]) { EditorGUILayout.BeginHorizontal(); { //EditorGUILayout.LabelField("List "+ i++); config.QuestionLists[i].ListSize = EditorGUILayout.IntField(config.QuestionLists[i].ListSize); config.QuestionLists[i].ListDifficulty = (Difficulty)EditorGUILayout.EnumPopup(config.QuestionLists[i].ListDifficulty); config.QuestionLists[i].Uniform = EditorGUILayout.Toggle("Uniform", config.QuestionLists[i].Uniform); } EditorGUILayout.EndHorizontal(); //List<string> subjects = config.QuestionLists[i].ListSubjects; for (int j = 0; j < config.QuestionLists[i].ListSubjects.Count; j++) { EditorGUILayout.BeginHorizontal(); { config.QuestionLists[i].ListSubjects[j] = EditorGUILayout.TextField(config.QuestionLists[i].ListSubjects[j]); if (GUILayout.Button("X")) { config.QuestionLists[i].ListSubjects.RemoveAt(j); break; } } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Add Subject")) { config.QuestionLists[i].ListSubjects.Add("Default"); } } EditorGUILayout.Space(); } if (GUILayout.Button("Add Question List")) { config.QuestionLists.Add(new QuestionListConfig(5, Difficulty.Easy, new List <string> { "Default" })); fold.Add(true); } }