Exemplo n.º 1
0
        void SetUpChapters(string chapterInfo)
        {
            JSONNode json = JSONNode.Parse(chapterInfo);

            for (int i = 0; i < json.Count; i++)
            {
                ChapterInitData nextChapter = new ChapterInitData();
                nextChapter.ChapterNumber      = json[i]["ChapterNumber"].AsInt;
                nextChapter.ChapterAnimalName  = json[i]["ChapterAnimalName"];
                nextChapter.ChapterMainColor   = HexUtility.HexToColor(json[i]["ChapterMainColor"]);
                nextChapter.ChapterSecondColor = HexUtility.HexToColor(json[i]["ChapterSecondColor"]);
                nextChapter.ChapterThirdColor  = HexUtility.HexToColor(json[i]["ChapterThirdColor"]);
                nextChapter.LevelInitList      = SetUpLevels(json[i]["Levels"], nextChapter.ChapterNumber, nextChapter.ChapterAnimalName);
                ChapterInitList.Add(nextChapter);
            }
        }
Exemplo n.º 2
0
        JSONArray GetChaptersData(JSONArray baseArray)
        {
            for (int i = 0; i < ChapterInitList.Count; i++)
            {
                JSONClass       newNode        = new JSONClass();
                ChapterInitData currentChapter = ChapterInitList[i];
                newNode["ChapterNumber"].AsInt     = currentChapter.ChapterNumber;
                newNode["ChapterBonusScore"].AsInt = currentChapter.ChapterBonusScore;
                newNode["ChapterBonusCoins"].AsInt = currentChapter.ChapterBonusCoins;
                newNode["ChapterAnimalName"]       = currentChapter.ChapterAnimalName;
                newNode["ChapterMainColor"]        = HexUtility.ColorToHex(currentChapter.ChapterMainColor);
                newNode["ChapterSecondColor"]      = HexUtility.ColorToHex(currentChapter.ChapterSecondColor);
                newNode["ChapterThirdColor"]       = HexUtility.ColorToHex(currentChapter.ChapterThirdColor);

                newNode["Levels"] = GetLevelsData(new JSONArray(), currentChapter);
                baseArray.Add(newNode);
            }
            return(baseArray);
        }