Example #1
0
    public static void ParseGameData(string str, bool isLevelEditor = false)
    {
        JsonData jsonData = null;

        jsonData = JsonMapper.ToObject(Resources.Load <TextAsset>("gamedata" + PlayerPrefsManager.GetLang().ToLower() + FugoUtils.getGameIndex()).text);
        JsonData data = jsonData["Sections"];

        sections = new List <Section>();
        ParseData(data, sections);
        string empty = string.Empty;

        if (empty != string.Empty)
        {
            List <Section> list = new List <Section>();
            try
            {
                JsonData jsonData2 = JsonMapper.ToObject(Resources.Load <TextAsset>("gamedata" + PlayerPrefsManager.GetLang().ToLower() + "ab" + empty).text);
                ParseData(jsonData2["Sections"], list);
                for (int i = 0; i < list.Count; i++)
                {
                    for (int j = 0; j < list[i].sets.Count; j++)
                    {
                        for (int k = 0; k < list[i].sets[j].levels.Count; k++)
                        {
                            sections[i].sets[j].levels[k] = list[i].sets[j].levels[k];
                        }
                    }
                }
            }
            catch
            {
                UnityEngine.Debug.Log("there is no ab levels");
            }
        }
        JsonData jsonData3 = jsonData["DailyLevels"];

        dailyPuzzles = new Section();
        for (int l = 0; l < jsonData3.Count; l++)
        {
            LevelSet levelSet  = new LevelSet(jsonData3[l]["SetID"].ToString(), jsonData3[l]["SectionID"].ToString(), jsonData3[l]["SetName"].ToString(), jsonData3[l]["SetFullName"].ToString(), jsonData3[l]["SetColor"].ToString(), jsonData3[l]["TitleColor"].ToString(), jsonData3[l]["RibbonColor"].ToString(), jsonData3[l]["CompletedLevelBGColor"].ToString(), jsonData3[l]["CompletedLevelLetterColor"].ToString(), jsonData3[l]["CompletedLevelNumberColor"].ToString(), jsonData3[l]["NotCompletedLevelBGColor"].ToString(), jsonData3[l]["NotCompletedLevelLetterColor"].ToString(), jsonData3[l]["NotCompletedLevelNumberColor"].ToString(), jsonData3[l]["SelectedLevelBGColor"].ToString(), jsonData3[l]["SelectedLevelLetterColor"].ToString(), jsonData3[l]["SelectedLevelNumberColor"].ToString(), jsonData3[l]["InGameLetterColor"].ToString(), jsonData3[l]["InGameCircleColor"].ToString(), jsonData3[l]["InGameSelectedLetterColor"].ToString(), jsonData3[l]["InGameSelectedLetterBGColor"].ToString(), jsonData3[l]["InGameHeaderColor"].ToString(), jsonData3[l]["InGameHintColor"].ToString(), jsonData3[l]["InGameRibbonColor"].ToString(), jsonData3[l]["InGameTileColor"].ToString(), jsonData3[l]["BackgroundImage"].ToString(), int.Parse(jsonData3[l]["XCoordinate"].ToString()), int.Parse(jsonData3[l]["YCoordinate"].ToString()), jsonData3[l]["TopText"].ToString(), jsonData3[l]["BottomText"].ToString());
            JsonData jsonData4 = jsonData3[l]["Levels"];
            for (int m = 0; m < jsonData4.Count; m++)
            {
                Level level = new Level();
                level.letters = jsonData4[m]["Letters"].ToString();
                level.id      = jsonData4[m]["LevelID"].ToString();
                level.height  = int.Parse(jsonData4[m]["Row"].ToString());
                level.width   = int.Parse(jsonData4[m]["Column"].ToString());
                try
                {
                    level.otherWords = jsonData4[m]["OtherWords"].ToString().Split(',');
                }
                catch (Exception)
                {
                }
                string[] array  = jsonData4[m]["Words"].ToString().Split('|');
                string[] array2 = array;
                foreach (string text in array2)
                {
                    string[] array3 = text.Split(',');
                    Word     word   = new Word();
                    word.Y         = int.Parse(array3[0]);
                    word.X         = int.Parse(array3[1]);
                    word.word      = array3[2];
                    word.length    = word.word.Length;
                    word.positions = new Vector3[word.length];
                    word.letters   = new GameObject[word.length];
                    if (array3[3] == "H" || array3[3] == "BH")
                    {
                        word.orientation = Orientation.HORIZONTAL;
                        if (array3[3] == "BH")
                        {
                            word.bonus = true;
                        }
                    }
                    else if (array3[3] == "V" || array3[3] == "BV")
                    {
                        word.orientation = Orientation.VERTICAL;
                        if (array3[3] == "BV")
                        {
                            word.bonus = true;
                        }
                    }
                    level.words.Add(word);
                }
                levelSet.levels.Add(level);
            }
            dailyPuzzles.sets.Add(levelSet);
        }
        Resources.UnloadUnusedAssets();
    }