public void LoadJsonFromFile(string file, LoadJTokenDelegate load, string dataId)
        {
            if (!File.Exists(file))
            {
                UnityEngine.Debug.LogError("LoadJsonFromFile::NoFile");
                return;
            }

            try
            {
                JToken root = JToken.Parse(File.ReadAllText(file));
                foreach (JToken jToken in !string.IsNullOrEmpty(dataId) ? root[dataId] : root as JArray ?? (IJEnumerable <JToken>)((JObject)root).PropertyValues())
                {
                    load(jToken, SetCodeDefault);
                }

                if (!string.IsNullOrEmpty(AllCardsUrlPageCountIdentifier) && root.Value <int>(AllCardsUrlPageCountIdentifier) > 0)
                {
                    AllCardsUrlPageCount = root.Value <int>(AllCardsUrlPageCountIdentifier);
                    if (AllCardsUrlPageCountDivisor > 0)
                    {
                        AllCardsUrlPageCount = UnityEngine.Mathf.CeilToInt(((float)AllCardsUrlPageCount) / AllCardsUrlPageCountDivisor);
                    }
                }
            }
            catch (Exception e)
            {
                Error    += e.Message + e.StackTrace + Environment.NewLine;
                HasLoaded = false;
            }
        }
Example #2
0
        public void LoadJsonFromFile(string file, LoadJTokenDelegate load, string dataId)
        {
            if (!File.Exists(file))
            {
                return;
            }

            JToken root = JToken.Parse(File.ReadAllText(file));

            foreach (JToken jToken in !string.IsNullOrEmpty(dataId) ? root[dataId] : root as JArray ?? (IJEnumerable <JToken>)((JObject)root).PropertyValues())
            {
                load(jToken, Set.DefaultCode);
            }

            if (!string.IsNullOrEmpty(AllCardsUrlPageCountIdentifier) && root.Value <int>(AllCardsUrlPageCountIdentifier) > 0)
            {
                AllCardsUrlPageCount = root.Value <int>(AllCardsUrlPageCountIdentifier);
                if (AllCardsUrlPageCountDivisor > 0)
                {
                    AllCardsUrlPageCount = UnityEngine.Mathf.CeilToInt(((float)AllCardsUrlPageCount) / AllCardsUrlPageCountDivisor);
                }
            }
        }