Example #1
0
        public QuestionArray loadJson()
        {
            using (StreamReader r = new StreamReader("./Assets/romana.json"))
            {
                string json = r.ReadToEnd();
                //Debug.Log(json);
                //List<Question> deserialized = JsonUtility.FromJson<List<Question>>(json);
                QuestionArray deserialized = JsonUtility.FromJson <QuestionArray>(json);

                //Debug.Log(deserialized.questions[0].getQuestion());
                for (int i = 0; i < deserialized.questions.Count; i++)
                {
                    if (deserialized.questions[i].getDificulty() != "easy")
                    {
                        deserialized.questions.RemoveAt(i); i--;
                    }
                    else
                    {
                        //Debug.Log(deserialized.questions[i].question);
                    }
                }
                //Debug.Log(deserialized.questions.Count);
                return(deserialized);
            }
        }
Example #2
0
 public QuestionArray loadJson()
 {
     using (StreamReader r = new StreamReader("./Assets/intrebari.json"))
     {
         string json = r.ReadToEnd();
         //Debug.Log(json);
         //List<Question> deserialized = JsonUtility.FromJson<List<Question>>(json);
         QuestionArray deserialized = JsonUtility.FromJson <QuestionArray>(json);
         //Debug.Log(deserialized.questions[0].getQuestion());
         return(deserialized);
     }
 }
Example #3
0
        public QuestionArray loadJson()
        {
            Debug.Log(MenuManager.getDifficulty());
            string language = MenuManager.getLanguage();

            if (language == "Romanian")
            {
                TextAsset r = (TextAsset)Resources.Load("Stiinta/romana", typeof(TextAsset));

                string json = r.text;
                //Debug.Log(json);
                //List<Question> deserialized = JsonUtility.FromJson<List<Question>>(json);
                QuestionArray deserialized = JsonUtility.FromJson <QuestionArray>(json);

                Debug.Log(deserialized.questions[0].getQuestion());
                for (int i = 0; i < deserialized.questions.Count; i++)
                {
                    if (deserialized.questions[i].getDificulty() != MenuManager.getDifficulty())
                    {
                        deserialized.questions.RemoveAt(i); i--;
                    }
                    else
                    {
                        //Debug.Log(deserialized.questions[i].question);
                    }
                }
                //Debug.Log(deserialized.questions.Count);
                return(deserialized);
            }
            else if (language == "English")
            {
                TextAsset r = (TextAsset)Resources.Load("Stiinta/engleza", typeof(TextAsset));

                string json = r.text;

                //Debug.Log(json);
                //List<Question> deserialized = JsonUtility.FromJson<List<Question>>(json);
                QuestionArray deserialized = JsonUtility.FromJson <QuestionArray>(json);

                //Debug.Log(deserialized.questions[0].getQuestion());
                for (int i = 0; i < deserialized.questions.Count; i++)
                {
                    if (deserialized.questions[i].getDificulty() != MenuManager.getDifficulty())
                    {
                        deserialized.questions.RemoveAt(i); i--;
                    }
                    else
                    {
                        //Debug.Log(deserialized.questions[i].question);
                    }
                }
                //Debug.Log(deserialized.questions.Count);
                return(deserialized);
            }
            else
            {
                TextAsset r = (TextAsset)Resources.Load("Stiinta/franceza", typeof(TextAsset));

                string json = r.text;
                //Debug.Log(json);
                //List<Question> deserialized = JsonUtility.FromJson<List<Question>>(json);
                QuestionArray deserialized = JsonUtility.FromJson <QuestionArray>(json);

                //Debug.Log(deserialized.questions[0].getQuestion());
                for (int i = 0; i < deserialized.questions.Count; i++)
                {
                    if (deserialized.questions[i].getDificulty() != MenuManager.getDifficulty())
                    {
                        deserialized.questions.RemoveAt(i); i--;
                    }
                    else
                    {
                        //Debug.Log(deserialized.questions[i].question);
                    }
                }
                //Debug.Log(deserialized.questions.Count);
                return(deserialized);
            }
        }