/// <summary>
        /// Sets the list landing item.
        /// </summary>
        /// <param name="pItem">P item.</param>
        private void SetListLandingItem(XsollaShopItem pItem)
        {
            if (mQuantityLabel == null)
            {
                return;
            }

            if ((pItem.GetQuantityLimit() > 1) || (pItem.GetQuantityLimit() == 0))
            {
                // Блок кол-ва
                if (mQuantityLabel != null && mQuantityCount != null)
                {
                    mQuantityLabel.text = mUtils.GetTranslations().Get("quantity_label");
                    mQuantityCount.text = mCount.ToString();
                }
                // События для кнопок изменения кол-ва товара
                if (mQuantityMinus != null && mQuantityPlus != null)
                {
                    mQuantityMinus.onClick.AddListener(MinusQuantity);
                    mQuantityPlus.onClick.AddListener(AddQuantity);
                }
            }
            else
            {
                // убираем панель с кол-вом
                mQuantityLabel.gameObject.SetActive(false);
                mQuantityPanel.SetActive(false);
            }
        }
        /// <summary>
        /// Buies the click.
        /// </summary>
        /// <param name="pItem">P item.</param>
        private void BuyClick(XsollaShopItem pItem)
        {
            Logger.Log("Click buy btn " + pItem.GetId());
            Dictionary <string, object> map = new Dictionary <string, object>();

            map.Add("sku[" + pItem.GetKey() + "]", mCount);
            gameObject.GetComponentInParent <XsollaPaystationController> ().ChooseItem(map, pItem.IsVirtualPayment());
        }
 /// <summary>
 /// Sets the ad block.
 /// </summary>
 /// <param name="pItem">P item.</param>
 private void SetAdBlock(XsollaShopItem pItem)
 {
     StyleManager.BaseSprite lItemBckg = ShopItemHelper.SetAdBlockItem(pItem, mUtils, mAdPanel.GetComponentInChildren <Text>(), mAdPanel.GetComponent <Image>());
     if ((lItemBckg == StyleManager.BaseSprite.bckg_item) && (mIsListLayoutItem))
     {
         mAdPanel.SetActive(false);
     }
     SetSpecialAdBkcg(lItemBckg);
 }
        /// <summary>
        /// Init the specified pItem, pUtils, pGroupId, pActionResetCacheGroup and pList.
        /// </summary>
        /// <param name="pItem">P item.</param>
        /// <param name="pUtils">P utils.</param>
        /// <param name="pGroupId">P group identifier.</param>
        /// <param name="pActionResetCacheGroup">P action reset cache group.</param>
        /// <param name="pList">If set to <c>true</c> p list.</param>
        public void init(XsollaShopItem pItem, XsollaUtils pUtils, int pGroupId, Action <int, bool> pActionResetCacheGroup, bool pList)
        {
            mItem    = pItem;
            mUtils   = pUtils;
            mGroupId = pGroupId;
            mActionResetCacheGroup = pActionResetCacheGroup;
            mIsListLayoutItem      = pList;

            // Загружаем картинку
            mImgLoader.LoadImage(mItemImg, pItem.GetImageUrl());

            // Задаем название
            mItemName.text = pItem.GetName();

            // Задаем короткое описание
            mShortDesc.text = pItem.GetDescription();

            // Дефолтное состояние прогресс бара
            ProgressBarBuyBtn(false);

            // Задаем полное описание
            if (mLongCanvas != null)
            {
                Resizer.ResizeToParrentRe(mLongCanvas.gameObject);
            }
            // Если полное описание пустое, то скрываем ссылку
            if (pItem.GetLongDescription() != "")
            {
                mLongDesc.text = pItem.GetLongDescription();
            }
            else
            {
                mLongDescLink.gameObject.SetActive(false);
            }

            // Задаем иконку любимого товара
            SetFavoriteState();
            mFav.gameObject.GetComponent <Button>().onClick.AddListener(delegate { ChangeFavState(); });

            // Задаем состояние длинного описания
            LongDescState = false;
            mLongDescLink.GetComponent <Button>().onClick.AddListener(delegate { SetStateLongState(!mLongDescState); });

            // Блокируем минус
            if (mQuantityMinus != null)
            {
                mQuantityMinus.interactable = false;
            }

            // Задаем поля для лэндинга list
            SetListLandingItem(pItem);
            // Рекламный блок
            SetAdBlock(pItem);
            // Ценовой блок
            SetAmountBlock(pItem.vcAmount, pItem.vcAmountWithoutDiscount, pItem.amount, pItem.amountWithoutDiscount, pItem.currency);
        }
Ejemplo n.º 5
0
        public static StyleManager.BaseSprite SetAdBlockItem(XsollaShopItem pItem, XsollaUtils pUtils, Text pLabel, Image pPanel)
        {
            bool isOffer = (pItem.amount != pItem.amountWithoutDiscount) || (pItem.vcAmount != pItem.vcAmountWithoutDiscount) || (pItem.bonusVirtualItems.Count > 0) || (pItem.bonusVirtualCurrency.quantity > 0);

            String lDisplaLabel;

            if (isOffer)
            {
                lDisplaLabel = pItem.offerLabel != "" ? pItem.offerLabel : pUtils.GetTranslations().Get("option_offer_desktop");
            }
            else
            {
                lDisplaLabel = pItem.label;
            }

            if (!isOffer && pItem.advertisementType != AXsollaShopItem.AdType.NONE)
            {
                switch (pItem.advertisementType)
                {
                case AXsollaShopItem.AdType.BEST_DEAL:
                {
                    pLabel.text    = pItem.label;
                    pPanel.enabled = true;
                    pPanel.sprite  = StyleManager.Instance.GetSprite(StyleManager.BaseSprite.bckg_bd_panel);
                    return(StyleManager.BaseSprite.bckg_item_bd);
                }

                case AXsollaShopItem.AdType.RECCOMENDED:
                {
                    pLabel.text    = pItem.label;
                    pPanel.enabled = true;
                    pPanel.sprite  = StyleManager.Instance.GetSprite(StyleManager.BaseSprite.bckg_ad_panel);
                    return(StyleManager.BaseSprite.bckg_item_ad);
                }

                case AXsollaShopItem.AdType.SPECIAL_OFFER:
                {
                    pLabel.text    = pItem.label;
                    pPanel.enabled = true;
                    pPanel.sprite  = StyleManager.Instance.GetSprite(StyleManager.BaseSprite.bckg_sales_panel);
                    return(StyleManager.BaseSprite.bckg_item_sales);
                }

                default:
                {
                    pPanel.color = new Color(255, 255, 255, 0);
                    pLabel.text  = "";
                    return(StyleManager.BaseSprite.bckg_item);
                }
                }
            }
            pPanel.color = new Color(255, 255, 255, 0);
            pLabel.text  = "";
            return(StyleManager.BaseSprite.bckg_item);
        }
Ejemplo n.º 6
0
        public override GameObject GetView(int position)
        {
            GameObject          shopItemInstance = Instantiate(shopItemPrefab) as GameObject;
            XsollaShopItem      item             = manager.GetItemByPosition(position);//manager.GetItemByPosition (position);
            ShopItemViewAdapter itemAdapter      = shopItemInstance.GetComponent <ShopItemViewAdapter>();

            itemAdapter.SetRealPrice(item.GetPriceString());
            itemAdapter.SetSpecial(item.GetBounusString());
            itemAdapter.SetCoins(item.GetDescription());
            itemAdapter.SetCoinsAmount(item.GetName());
            itemAdapter.SetImage(item.GetImageUrl());
            itemAdapter.SetOnClickListener(() => OnClickBuy("sku[" + item.GetKey() + "]"));
            return(shopItemInstance);
        }
Ejemplo n.º 7
0
        private void AddShopItem(XsollaShopItem pItem)
        {
            GameObject lBaseObj = Resources.Load(mIsListLayout ? PREFAB_SHOP_ITEM_LIST : PREFAB_SHOP_ITEM_GRID) as GameObject;
            // создаем экземпляр объекта товара
            GameObject lItemObj = Instantiate(lBaseObj);
            // получаем контроллер
            ShopItemController itemController = lItemObj.GetComponent <ShopItemController>();

            // инициализируем контроллер
            itemController.init(pItem, mUtils, mCurrGroupId, SetCachedStateOnGroupId, mIsListLayout);
            itemController.mCollapseAnotherDesc = CollapseAllDesc;
            // добавляем на панель
            lItemObj.transform.SetParent(GetItemContainer.transform);
            // масштабирование
            Resizer.SetDefScale(lItemObj);
            // Добавляем в лист кэша магазина
            mListItems.Add(itemController);
        }
Ejemplo n.º 8
0
        public override GameObject GetView(int position)
        {
            GameObject shopItemInstance = Instantiate(shopItemPrefab) as GameObject;

            shopItemInstance.name = "ShopItemGood " + position;
            XsollaShopItem      item        = manager.GetItemByPosition(position); //manager.GetItemByPosition (position);
            ShopItemViewAdapter itemAdapter = shopItemInstance.GetComponent <ShopItemViewAdapter>();

            itemAdapter.SetPrice(item.GetPriceString());
            itemAdapter.SetSpecial(item.GetBounusString());
            itemAdapter.SetDesc(item.GetDescription());
            itemAdapter.SetName(item.GetName());
            itemAdapter.SetFullDesc(item.GetLongDescription());
            itemAdapter.SetBuyText("Buy");
            itemAdapter.SetImage(item.GetImageUrl());
            itemAdapter.SetFavorite(item.IsFavorite());
            itemAdapter.SetOnClickListener(() => OnClickBuy("sku[" + item.GetKey() + "]", item.IsVirtualPayment()));
            itemAdapter.SetOnFavoriteChanged((b) => OnClickFavorite(b, "sku[" + item.GetKey() + "]", item.GetId()));
            itemAdapter.SetLabel(item.GetAdvertisementType(), item.GetLabel());
            return(shopItemInstance);
        }