private void LoadLogFiles() { Debug.Log("Loading AvailableFractals.json"); AppSession.AvailableFractals = FractalLog.LoadLog(LogNames.AvailableFractals, FractalLog.OpLocation.Resources).Fractals; Debug.Log("Loading DownloadedFractals from playerprefs"); AppSession.DownloadedFractals = FractalLog.LoadLog(LogNames.DownloadedFractals).Fractals; Debug.Log("Downloaded Fractal Count: " + AppSession.DownloadedFractals.Count); if (AppSession.FirstTimeUser || (!AppSession.FirstTimeUser && AppSession.DownloadedFractals.Count == 0)) { AddPreinstalledExperiences(); } Debug.Log("Downloaded Fractal Count: " + AppSession.DownloadedFractals.Count); IAP.GetViewerPurchases().OnComplete(message => { if (message == null || message.IsError) { Debug.Log("Player purchases could not be retrieved. Defaulting to local copy of purchases."); AppSession.PurchasedFractals = PlayerPrefs.HasKey(LogNames.PurchasedFractals) ? FractalLog.LoadLog(LogNames.PurchasedFractals).Fractals : new List <Fractal>(); } else { var list = new List <Fractal>(); for (var i = 0; i < message.Data.Count; i++) { var data = message.Data[i]; var fractal = new Fractal { Name = FractalLog.GetElementBySku(AppSession.AvailableFractals, data.Sku).Name, Sku = data.Sku, Type = 1 }; list.Add(fractal); } AppSession.PurchasedFractals = list; Debug.Log("Purchased fractals length:" + list.Count); PlayerPrefs.SetString(LogNames.PurchasedFractals, JsonUtility.ToJson(list)); PlayerPrefs.Save(); } }); _logFilesLoaded = true; }
public static FractalLog ListToFractalLog(PurchaseList list) { Assert.IsNotNull(list); var log = new FractalLog(); log.Fractals = new List <Fractal>(); Assert.IsNotNull(log, "Log is NULL"); Assert.IsNotNull(log.Fractals, "Log.Fractals is null"); for (var i = 0; i < list.Count; i++) { Assert.IsNotNull(FractalLog.GetElementBySku(AppSession.DownloadedFractals, list[i].Sku), "FractalLog.GetElementBySku(AppSession.DownloadedFractals, list[i].Sku) != null"); Assert.IsNotNull(""); log.Fractals.Add(new Fractal { Name = FractalLog.GetElementBySku(AppSession.DownloadedFractals, list[i].Sku).Name, Sku = list[i].Sku, Type = 1 }); } return(log); }