Esempio n. 1
0
        public void Select()
        {
            var newMenuType = Menu.Type.Download;
            var menu        = WindowManager.Instance.GetWindow <Menu>(WindowNames.Menu);

            if (Menu.IsItemOpen(Name))
            {
                Menu.GetOpenItem(Name);
            }
            else
            {
                if (FractalLog.Contains(AppSession.DownloadedFractals, Fractal.Name))
                {
                    newMenuType = Menu.Type.View;
                }
                else if ((Cost <= 0 || PurchaseRequest.Purchased(Fractal.Name)) && AppSession.IsConnectedToInternet)
                {
                    newMenuType = Menu.Type.Download;
                }
                else if (Cost > 0 && AppSession.IsConnectedToInternet)
                {
                    newMenuType = Menu.Type.Purchase;
                }
                else if (!AppSession.IsConnectedToInternet)
                {
                    WindowManager.Instance.ChangeWindow(WindowNames.OfflineWindow);
                    return;
                }
                WindowManager.Instance.ChangeWindow(menu.gameObject);
                menu.Setup(this, newMenuType);
            }
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        private IEnumerator SetupGodCanvas()
        {
            var libraryWindow = GetWindow <PrimaryWindow>(WindowNames.LibraryWindow);
            var storeWindow   = GetWindow <PrimaryWindow>(WindowNames.StoreWindow);

            FractalLog.Print(_availableItems, "Available Fractals");
            FractalLog.Print(_downloadedItems, "Downloaded Fractals");

            var items = ListIntersection(_availableItems, _downloadedItems);

            FractalLog.Print(items[0], "Store Fractals");
            FractalLog.Print(items[1], "Library Fractals");
            yield return(null);

            libraryWindow.gameObject.SetActive(true);
            storeWindow.gameObject.SetActive(true);
            AppData.Ref.StaticBackground.SetActive(true);
            AppData.Ref.NavigationPanel.SetActive(true);
            yield return(null);

            if (AppSession.IsConnectedToInternet)
            {
                yield return(StartCoroutine(storeWindow.Populate(items[0])));

                items[1].Add(new Fractal {
                    Name = ExplorationMenuItem, Type = 0
                });
            }
            yield return(StartCoroutine(libraryWindow.Populate(items[1])));

            if (AppSession.FirstTimeUser)
            {
                ChangeWindow(WindowNames.IntroductionWindow, false);
            }
            else if (AppSession.UpdateAvailable)
            {
                GetWindow <AppUpdateWindow>(WindowNames.AppUpdateWindow).Setup(AppSession.AppUpdate);
                ChangeWindow(WindowNames.AppUpdateWindow, false);
            }
            else
            {
                ChangeWindow(WindowNames.LibraryWindow);
            }
            storeWindow.gameObject.SetActive(false);
            AppSession.AppCamera.cullingMask = -1;
        }
Esempio n. 4
0
        private void AddPreinstalledExperiences()
        {
            for (var i = 0; i < _embeddedExps.Count; i++)
            {
                var fractal = new Fractal {
                    Name = _embeddedExps[i], Type = 0
                };
                AppSession.DownloadedFractals.Add(fractal);
            }
            var log = new FractalLog {
                Fractals = AppSession.DownloadedFractals
            };

            var str = JsonUtility.ToJson(log);

            PlayerPrefs.SetString(LogNames.DownloadedFractals, str);
            PlayerPrefs.Save();
        }
        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);
        }
        private IEnumerator HandleUninstall()
        {
            yield return(RequestProcessor.Instance.StartCoroutine(_uninstallJob.Start()));

            if (MonoAssetIo.Instance.Success)
            {
                var fractalLog = new FractalLog();

                for (var i = 0; i < AppSession.DownloadedFractals.Count; i++)
                {
                    if (AppSession.DownloadedFractals[i].Name == _fractal.Name)
                    {
                        AppSession.DownloadedFractals.RemoveAt(i);
                    }
                }
                fractalLog.Fractals = AppSession.DownloadedFractals;
                PlayerPrefs.SetString(LogNames.DownloadedFractals, JsonUtility.ToJson(fractalLog));
                PlayerPrefs.Save();
            }
            _callback(MonoAssetIo.Instance.Success, this);
        }
Esempio n. 7
0
        public static FractalLog LoadLog(string id, OpLocation location = OpLocation.PlayerPrefs)
        {
            switch (location)
            {
            case OpLocation.PlayerPrefs:
                if (PlayerPrefs.HasKey(id))
                {
                    return(JsonUtility.FromJson <FractalLog>(PlayerPrefs.GetString(id)));
                }
                else
                {
                    var log = new FractalLog();
                    log.Fractals = new List <Fractal>();
                    return(log);
                }

            case OpLocation.Resources:
                return(JsonUtility.FromJson <FractalLog>(Resources.Load <TextAsset>(id).text));
            }
            return(null);
        }
Esempio n. 8
0
        private static List <Fractal>[] ListIntersection(List <Fractal> l1, List <Fractal> l2)
        {
            var newL1 = new List <Fractal>(); //Where l2 is a subset of l1
            var newL2 = new List <Fractal>();

            Debug.Log(l1);
            Debug.Log(l2);

            for (var i = 0; i < l1.Count; i++)
            {
                if (FractalLog.Contains(l2, l1[i].Name))
                {
                    newL2.Add(l1[i]);
                }
                else
                {
                    newL1.Add(l1[i]);
                }
            }
            Debug.Log(l1.Count);
            Debug.Log(l2.Count);
            return(new[] { newL1, newL2 });
        }