Esempio n. 1
0
        private IEnumerator ResizeSubCategories(ShopData _shopData)
        {
            yield return(new WaitForEndOfFrame());

            for (int i = 0; i < categories.Count; i++)
            {
                CategoryVisual categoryVisual = categories[i];
                if (categoryVisual != null)
                {
                    categoryVisual.ResizeSubCategories(_shopData.line, _shopData.column, _shopData.categories[i]);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Update the shop view based on _shop
        /// </summary>
        /// <param name="shopData"></param>
        public void UpdateShopView(ShopData shopData)
        {
            if (shopData == null || categories == null || categories.Count == 0)
            {
                return;
            }

            for (int i = 0; i < categories.Count; i++)
            {
                CategoryVisual categoryVisual = categories[i];
                if (categoryVisual)
                {
                    categoryVisual.UpdateCategory(shopData.categories[i]);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Create and initialize the shop view based on _shopData.
        /// This method is called automatically in the Initialize method of the Shop.
        /// </summary>
        /// <param name="_shopData"></param>
        public void CreateVisualShop(ShopData _shopData)
        {
            categories     = new List <CategoryVisual>();
            chestRoomText  = chestRoomArea.GetComponentInChildren <TextMeshProUGUI>(true);
            comingSoonText = comingSoonArea.GetComponentInChildren <TextMeshProUGUI>(true);
            titleText      = header.GetComponentInChildren <TextMeshProUGUI>(true);
            canvas         = GetComponentInParent <Canvas>();
            canvasGroup    = GetComponent <CanvasGroup>();
            camera         = canvas.GetComponentInChildren <Camera>(true);
            shop           = Shop.Instance;

            if (_shopData == null)
            {
                return;
            }

            if (rvButton != null)
            {
                rvButton.UpdateValue(_shopData.RVBonusCurrency, _shopData.RVBonusValue);
            }

            if (paymentPicker != null)
            {
                paymentPicker.buttonPicker.onClick.AddListener(RequestPurchase);
            }

            if (scrollRect != null)
            {
//					List<CategoryDataServer> categoryDataServers = RemoteConfigManager.Instance.List<CategoryDataServer>();

                for (var i = 0; i < _shopData.categories.Count; i++)
                {
                    CategoryData categoryData = _shopData.categories[i];

//						CategoryDataServer categoryDataServer = categoryDataServers.Find(x => x.id == categoryData.id);
//						if (categoryDataServer != null)
//							categoryData.Initialize(categoryDataServer);

                    CategoryVisual categoryVisual = categoryData.AddShopCategory(scrollRect, subCategoryDotZoneParent);
                    categories.Add(categoryVisual);
                }
            }

            StartCoroutine(ResizeSubCategories(_shopData));
        }
Esempio n. 4
0
        /// <summary>
        /// Display the chosen category _categoryData.
        /// Show the Shop if it's not visible.
        ///	Will automatically update the preview with the currently used skin.
        ///	Will directly move to the page corresponding to the skin's subcategory
        /// </summary>
        /// <param name="_categoryData"></param>
        public void ShowCategory(CategoryData _categoryData)
        {
            if (categories == null || _categoryData == null)
            {
                return;
            }

            bool isAlreadyInShop = m_Visible;

            if (!isAlreadyInShop)
            {
                Show();
            }

            for (var i = 0; i < categories.Count; i++)
            {
                CategoryVisual categoryVisual = categories[i];

                if (categoryVisual.name == _categoryData.name)
                {
                    categoryVisual.Show();
                }
                else
                {
                    categoryVisual.Hide();
                }
            }

            if (isAlreadyInShop)
            {
                if (shop.currentlyUsedSkins.ContainsKey(_categoryData))
                {
                    UpdateSkinPreview(shop.currentlyUsedSkins[_categoryData]);
                }
                else
                {
                    UpdateSkinPreview(null);
                }
            }

            int usedItemPageIndex = 0;

            for (var i = 0; i < _categoryData.subCategories.Count; i++)
            {
                SubCategoryData subCategoryData = _categoryData.subCategories[i];

                if (subCategoryData is SubCategorySkinData subCategorySkinData)
                {
                    if (subCategorySkinData.skins.Exists(skin => skin.IsUsed))
                    {
                        usedItemPageIndex = i;
                        break;
                    }
                }
                else if (subCategoryData is SubCategoryBundleData subCategoryBundleData)
                {
                    //TODO
                }
            }

            scrollRect.ChangePage(usedItemPageIndex, true);
        }