コード例 #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        QuestionLibrary myScript = (QuestionLibrary)target;

        if (GUILayout.Button("Build Question Set"))
        {
            myScript.GenerateQuestions();
        }
        if (GUILayout.Button("Shuffle Questions"))
        {
            myScript.ShuffleQuestions();
        }
        if (GUILayout.Button("Clear Stats"))
        {
            myScript.ClearStats();
        }
    }
コード例 #2
0
        // Populates the QuestionLibrary with new Questions from the CSV
        public static void ParseQuestions(string resourcePath)
        {
            List <List <string> > csv       = ParseCSV(resourcePath);
            List <string>         replies   = new List <string>();
            List <Dialogue>       responses = new List <Dialogue>();
            List <int>            deltas    = new List <int>();

            // Questions are exactly four lines long each
            for (int i = 0; i < csv.Count - csv.Count % 4; i += 4)
            {
                for (int j = 0; j < csv[i + 1].Count; j++)
                {
                    if (!string.IsNullOrWhiteSpace(csv[i + 1][j]) &&
                        !string.IsNullOrWhiteSpace(csv[i + 2][j]) &&
                        !string.IsNullOrWhiteSpace(csv[i + 3][j]))
                    {
                        //Debug.Log(" [" + csv[i + 1][j] + ":" + csv[i + 2][j] + ":" + csv[i + 3][j] + "]");
                        replies.Add(csv[i + 1][j]);
                        //Debug.Log("("+i+":"+j+") "+csv[i + 2][j]);
                        responses.Add(DialogueLibrary[csv[i + 2][j]]);
                        deltas.Add(int.Parse(csv[i + 3][j]));
                        //Debug.Log(" [" + replies[j] + ":" + deltas[j] + " -> " + responses[j] + "]");
                    }
                }

                string[] filteredTags = csv[i][5].Split(' ').Where(a => !String.IsNullOrWhiteSpace(a)).ToArray();
                QuestionLibrary.Add(csv[i][0],
                                    new Question(csv[i][1],
                                                 csv[i][2],
                                                 csv[i][3],
                                                 csv[i][4],
                                                 filteredTags,
                                                 replies.ToArray(),
                                                 DialogueLibrary[csv[i + 2][0]],
                                                 responses.ToArray(),
                                                 deltas.ToArray()));

                replies   = new List <string>();
                responses = new List <Dialogue>();
                deltas    = new List <int>();
            }
        }
コード例 #3
0
 public override void Open()
 {
     base.Open();
     roundSize = GameManager.Instance.config.roundSize;
     roundTime = GameManager.Instance.config.roundTime;
     if (difficulty == DIFFICULTY.MARATHON)
     {
         timeSlider.maxValue = roundTime;
         _roundTime          = roundTime;
         lives = 3;
         livesText.gameObject.SetActive(true);
     }
     else
     {
         livesText.gameObject.SetActive(false);
     }
     library         = GameManager.Instance.PlayQuestionSet();
     currentQuestion = 0;
     localstats      = new Stats();
     SetQuestions();
     GenerateQuestion();
 }