示例#1
0
        public override GameObject GetView(int position)
        {
            XsollaSubscription subscription = GetItem(position);
            GameObject         subcriptionInstance;

            if (subscription.IsSpecial())
            {
                subcriptionInstance = Instantiate(subscriptionSpecialPrefab);
            }
            else
            {
                subcriptionInstance = Instantiate(subscriptionPrefab);
            }
            ShopItemViewAdapter itemAdapter = subcriptionInstance.GetComponentInChildren <ShopItemViewAdapter>();

            itemAdapter.SetPrice(subscription.name);                  //1
            itemAdapter.SetSpecial(subscription.description);         //2 //GetBounusString()
            itemAdapter.SetDesc(subscription.GetPriceString());       //3
            itemAdapter.SetName(subscription.GetPeriodString("per")); //4
            itemAdapter.SetOnClickListener(() => OnClickBuy(subscription.id));
            return(subcriptionInstance);
        }
        public void InitBtn(XsollaSubscription pSub, XsollaTranslations pTranslation)
        {
            _sub          = pSub;
            _subName.text = _sub.GetName();

            if (_sub.description != null)
            {
                _desc.GetComponent <Text>().text = _sub.description;
                _desc.SetActive(true);
            }
            else
            {
                _desc.SetActive(false);
            }

            if (!_sub.IsSpecial())
            {
                _newPrice.text = CurrencyFormatter.Instance.FormatPrice(_sub.chargeCurrency, _sub.chargeAmount);
                _oldPrice.gameObject.SetActive(false);
            }
            else
            {
                _oldPrice.text = CurrencyFormatter.Instance.FormatPrice(_sub.chargeCurrency, _sub.chargeAmountWithoutDiscount);
                _newPrice.text = CurrencyFormatter.Instance.FormatPrice(_sub.chargeCurrency, _sub.chargeAmount);
                _offerText.GetComponent <Text>().text = pTranslation.Get("option_offer");
            }
            _offerText.SetActive(_sub.IsSpecial()?true:false);
            _offerImagePanel.enabled = _sub.IsSpecial()?true:false;

            _period.text = _sub.GetPeriodString("Every");

            _btnSub.onClick.AddListener(() => {
                Dictionary <string, object> purchase = new Dictionary <string, object>();
                purchase.Add("id_package", _sub.id);

                gameObject.GetComponentInParent <XsollaPaystationController> ().ChooseItem(purchase, false);
            });
        }