Exemple #1
0
    public static QuestionsContainer Load(string path)
    {
        TextAsset _xml = Resources.Load <TextAsset>(path);

        XmlSerializer serializer = new XmlSerializer(typeof(QuestionsContainer));

        StringReader reader = new StringReader(_xml.text);

        QuestionsContainer questionsList = serializer.Deserialize(reader) as QuestionsContainer;

        reader.Close();

        return(questionsList);
    }
    void Start()
    {
        AdManager.instance.gamesPlayed++;
        SoundStatus();
        score         = 0;                                 //at start we want score to be zero
        hiScore       = PlayerPrefs.GetInt("HiScore");     //we get the saved hiscore
        timePerQues   = 4;                                 //we set max time for question
        buttonClicked = false;                             //at start the player input is nothing
        isGameOver    = false;                             //at start the game is not over
        audioSource   = GetComponent <AudioSource>();      // we get the component attached to game object
        //at start we need to add xml data to questions array
        QuestionsContainer qc = QuestionsContainer.Load(path);

        questions = qc.questionsList.ToArray();        //we store data from questionList into questions array

        SetCurrentQuestion();                          //we call the question setting method
    }
Exemple #3
0
    private void Start()
    {
        QuestionsContainer qc = QuestionsContainer.Load(path);

        quests = qc.questionsList;
    }
        /// <summary>
        /// Writes the datafiles, asking the user for overwriting.
        /// </summary>
        /// <param name="gestures">Gestures list container</param>
        /// <param name="categories">Categories list container.</param>
        /// <param name="locations">Locations list container.</param>
        /// <param name="names">Names list container.</param>
        /// <param name="questions">Questions list container.</param>
        private static void WriteDatafiles(GestureContainer gestures, CategoryContainer categories, RoomContainer locations, NameContainer names, QuestionsContainer questions)
        {
            string path = Loader.GetPath("Gestures.xml");

            if (Overwrite(path))
            {
                Loader.Save(path, gestures);
            }
            path = Loader.GetPath("Locations.xml");
            if (Overwrite(path))
            {
                Loader.Save(path, locations);
            }
            path = Loader.GetPath("Names.xml");
            if (Overwrite(path))
            {
                Loader.Save(path, names);
            }
            path = Loader.GetPath("Objects.xml");
            if (Overwrite(path))
            {
                Loader.Save(path, categories);
            }
            path = Loader.GetPath("Questions.xml");
            if (Overwrite(path))
            {
                Loader.Save(path, questions);
            }
        }