protected virtual void onElementShown(int index, GameObject element)
        {
            if (!(element != null))
            {
                return;
            }
            if (buyPanel == null)
            {
                LayoutElement component = element.transform.parent.gameObject.GetComponent <LayoutElement>();
                if (component != null)
                {
                    component.preferredHeight = element.GetComponent <LayoutElement>().preferredHeight;
                }
            }
            CatalogShopRowItem component2 = element.GetComponent <CatalogShopRowItem>();

            if (component2 != null)
            {
                component2.ClearShopItems();
                int catalogShopItemsPerRow = CatalogShopItemsPerRow;
                if (index + 1 - IndexOffset == numShopRows)
                {
                    catalogShopItemsPerRow = lastRowNumItems;
                }
                int num = 1;
                while (num <= catalogShopItemsPerRow)
                {
                    int             index2          = (index - IndexOffset) * CatalogShopItemsPerRow + (num - 1);
                    CatalogShopItem catalogShopItem = component2.AddShopItem(index - IndexOffset, num);
                    num++;
                    catalogShopItem.SetUpButton(filteredItems[index2], foregroundColor, backgroundColor, HideItemName);
                }
            }
        }
Пример #2
0
        public CatalogShopItem AddShopItem(int scrollIndex, int rowIndex, bool isHideCreatorName = false)
        {
            CatalogShopItem catalogShopItem = Object.Instantiate(ShopItem);

            catalogShopItem.GetComponent <CatalogShopItem>().SetRowIndex(rowIndex);
            catalogShopItem.GetComponent <CatalogShopItem>().SetScrollIndex(scrollIndex);
            catalogShopItem.transform.SetParent(Layout.transform, worldPositionStays: false);
            if (isHideCreatorName)
            {
                catalogShopItem.DisableName();
            }
            shopItems.Add(catalogShopItem);
            return(catalogShopItem);
        }
        public virtual void ShowShopItemPanel(int scrollIndex, int rowIndex, bool isMemberUnlocked, bool isRecentlyPurchased)
        {
            int             index      = scrollIndex * CatalogShopItemsPerRow + (rowIndex - 1);
            CatalogItemData itemData   = filteredItems[index];
            int             arrowIndex = rowIndex - 1;

            try
            {
                GameObject elementAtIndex = Scroller.GetElementAtIndex(scrollIndex + IndexOffset);
                if (elementAtIndex != null)
                {
                    CatalogShopRowItem component = elementAtIndex.GetComponent <CatalogShopRowItem>();
                    if (component != null)
                    {
                        int count = component.GetShopItems().Count;
                        if (count == 1)
                        {
                            arrowIndex = 1;
                        }
                        if (count == 2)
                        {
                            arrowIndex = CatalogShopItemsPerRow + rowIndex - 1;
                        }
                        CatalogShopItem catalogShopItem = component.GetShopItems()[rowIndex - 1];
                        catalogShopItem.AddListeners();
                    }
                }
            }
            catch (Exception)
            {
            }
            selectedItem = itemData;
            bool flag = false;

            if (buyPanel != null)
            {
                if (buyPanel.ElementIndex == scrollIndex)
                {
                    buyPanel.SetPanel(itemData, scrollIndex, arrowIndex, isMemberUnlocked, isRecentlyPurchased);
                    flag = true;
                }
                else
                {
                    CloseBuyPanel();
                }
            }
            if (flag)
            {
                return;
            }
            GameObject elementAtIndex2 = Scroller.GetElementAtIndex(scrollIndex + IndexOffset);

            if (elementAtIndex2 != null)
            {
                LayoutElement component2 = elementAtIndex2.transform.parent.gameObject.GetComponent <LayoutElement>();
                if (component2 != null)
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate(ClothingPurchase);
                    DefaultValuesPooledLayoutElement component3 = gameObject.GetComponent <DefaultValuesPooledLayoutElement>();
                    component2.preferredHeight = component3.DefaultHeight + elementAtIndex2.GetComponent <LayoutElement>().preferredHeight;
                    gameObject.transform.SetParent(elementAtIndex2.transform, worldPositionStays: false);
                    buyPanel      = gameObject.GetComponent <CatalogShopBuyPanelController>();
                    buyPanelIndex = scrollIndex;
                    buyPanel.SetPanel(itemData, scrollIndex, arrowIndex, isMemberUnlocked, isRecentlyPurchased);
                    CoroutineRunner.Start(ScrollToElement(scrollIndex + IndexOffset), this, "ScrollToElement");
                }
            }
        }