示例#1
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;
        }
示例#2
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
    }