Exemplo n.º 1
0
    void OnQuestionListReceive(MultipleChoiceQuestionList questionList)
    {
        mIsQuestionsReceived = true;

        mQuestionsList         = questionList;
        mQuestionsAnsweredList = new List <QuestionAnswered>(mQuestionsList.questions.Length);
    }
Exemplo n.º 2
0
    // Store the questions and show them in order based on your game flow.
    protected void HandleQuestions(MultipleChoiceQuestionList questionList)
    {
        mIsQuestionsReceived = true;

        mQuestionsList         = questionList;
        mQuestionsAnsweredList = new List <QuestionAnswered>(mQuestionsList.questions.Length);
    }
Exemplo n.º 3
0
        void LoadMockData()
        {
            mLangCode = ((LoLLocalize)M8.Localize.instance).editorLanguageCode;

            //apply start data
            string startDataFilePath = Path.Combine(Application.streamingAssetsPath, startGameJSONFilePath);

            if (File.Exists(startDataFilePath))
            {
                mGameStartJson = File.ReadAllText(startDataFilePath);
            }
            else
            {
                mGameStartJson = "";
            }
            //

            //apply language
            string langFilePath = ((LoLLocalize)M8.Localize.instance).editorLanguagePath;

            if (File.Exists(langFilePath))
            {
                string json = File.ReadAllText(langFilePath);

                var langDefs = Json.Deserialize(json) as Dictionary <string, object>;
                mLanguageJson = Json.Serialize(langDefs[mLangCode]);
            }
            else
            {
                mLanguageJson = "";
            }
            //

            //apply questions
            string questionsFilePath = Path.Combine(Application.streamingAssetsPath, questionsJSONFilePath);

            if (File.Exists(questionsFilePath))
            {
                string questionsDataAsJson    = File.ReadAllText(questionsFilePath);
                MultipleChoiceQuestionList qs = MultipleChoiceQuestionList.CreateFromJSON(questionsDataAsJson);
                HandleQuestions(qs);
            }
            //

            mIsGameStartHandled = true;
            mIsLanguageHandled  = true;
        }
Exemplo n.º 4
0
    private void LoadMockData()
    {
                #if UNITY_EDITOR
        // Load Dev Language File from StreamingAssets

        string startDataFilePath = Path.Combine(Application.streamingAssetsPath, startGameJSONFilePath);
        string langCode          = "en";

        Debug.Log(File.Exists(startDataFilePath));

        if (File.Exists(startDataFilePath))
        {
            string   startDataAsJSON  = File.ReadAllText(startDataFilePath);
            JSONNode startGamePayload = JSON.Parse(startDataAsJSON);
            // Capture the language code from the start payload. Use this to switch fontss
            langCode = startGamePayload["languageCode"];
            HandleStartGame(startDataAsJSON);
        }

        // Load Dev Language File from StreamingAssets
        string langFilePath = Path.Combine(Application.streamingAssetsPath, languageJSONFilePath);
        if (File.Exists(langFilePath))
        {
            string langDataAsJson = File.ReadAllText(langFilePath);
            // The dev payload in language.json includes all languages.
            // Parse this file as JSON, encode, and stringify to mock
            // the platform payload, which includes only a single language.
            JSONNode langDefs = JSON.Parse(langDataAsJson);
            // use the languageCode from startGame.json captured above
            HandleLanguageDefs(langDefs[langCode].ToString());
        }

        // Load Dev Questions from StreamingAssets
        string questionsFilePath = Path.Combine(Application.streamingAssetsPath, questionsJSONFilePath);
        if (File.Exists(questionsFilePath))
        {
            string questionsDataAsJson    = File.ReadAllText(questionsFilePath);
            MultipleChoiceQuestionList qs =
                MultipleChoiceQuestionList.CreateFromJSON(questionsDataAsJson);
            HandleQuestions(qs);
        }
                #endif
    }
Exemplo n.º 5
0
 // Store the questions and show them in order based on your game flow.
 void HandleQuestions(MultipleChoiceQuestionList questionList)
 {
     Debug.Log("HandleQuestions");
     SharedState.QuestionList = questionList;
 }
Exemplo n.º 6
0
 public void QuestionsReceived(MultipleChoiceQuestionList questionList)
 {
     this.questionList = questionList;
 }
Exemplo n.º 7
0
    private void CreateDummyQuestions()
    {
        Alternative alternative1 = new Alternative();

        alternative1.text          = "blue";
        alternative1.alternativeId = "1";

        Alternative alternative2 = new Alternative();

        alternative2.text          = "red";
        alternative2.alternativeId = "2";

        Alternative alternative3 = new Alternative();

        alternative3.text          = "yellow";
        alternative3.alternativeId = "3";

        Alternative alternative4 = new Alternative();

        alternative4.text          = "green";
        alternative4.alternativeId = "4";

        MultipleChoiceQuestion question1 = new MultipleChoiceQuestion();

        question1.stem                 = "What is your favorite color? [IMAGE]";
        question1.questionId           = "1";
        question1.correctAlternativeId = "1";
        question1.alternatives         = new Alternative[] { alternative1, alternative2, alternative3, alternative4 };
        question1.imageURL             = "http://s3.amazonaws.com/game-harness/images/red-green-and-blue-eye.jpg";

        Alternative alternative5 = new Alternative();

        alternative5.text          = "Of course I like pie. All pie is good pie";
        alternative5.alternativeId = "5";

        Alternative alternative6 = new Alternative();

        alternative6.text          = "No";
        alternative6.alternativeId = "6";

        Alternative alternative7 = new Alternative();

        alternative7.text          = "Only apple pie";
        alternative7.alternativeId = "7";

        Alternative alternative8 = new Alternative();

        alternative8.text          = "Yes, Pi is the best number ever. ";
        alternative8.alternativeId = "8";

        MultipleChoiceQuestion question2 = new MultipleChoiceQuestion();

        question2.stem                 = "This is a very very long question with an image in the middle of it. By long I mean it just goes on and on and on without reason. [IMAGE] The actual question is simply this: Do you like pie? Well, do you? If not, why on earth not? Who does't like pie?";
        question2.questionId           = "2";
        question2.correctAlternativeId = "5";
        question2.alternatives         = new Alternative[] { alternative5, alternative6, alternative7, alternative8 };
        question2.imageURL             = "http://s3.amazonaws.com/game-harness/images/red-green-and-blue-eye.jpg";

        MultipleChoiceQuestion question3 = new MultipleChoiceQuestion();

        question3.stem                 = "This is a very very long question with no image in the middle of it. Also no image at the end. Or the beginning. By long I mean it just goes on and on and on without reason. The actual question is simply this: Do you like pie? Well, do you? If not, why on earth not? Who does't like pie?";
        question3.questionId           = "3";
        question3.correctAlternativeId = "5";
        question3.alternatives         = new Alternative[] { alternative5, alternative6, alternative7, alternative8 };
        question3.imageURL             = null;

        MultipleChoiceQuestionList dummyList = new MultipleChoiceQuestionList();

        dummyList.questions = new MultipleChoiceQuestion[] { question1, question2, question3 };

        mIsQuestionsReceived = true;

        mQuestionsList         = dummyList;
        mQuestionsAnsweredList = new List <QuestionAnswered>(mQuestionsList.questions.Length);
    }