示例#1
0
 internal void initBuyResourceAmounts(PremiumProduct prod)
 {
     this.BuyResourceAmounts.Clear();
     foreach (ProductReward reward in ConfigShops.GetRewardsFromProduct(prod))
     {
         try
         {
             ResourceType key = (ResourceType)((int)Enum.Parse(typeof(ResourceType), reward.key));
             this.BuyResourceAmounts.Add(key, (double)reward.amount);
         }
         catch (Exception)
         {
             Debug.Log("ShopEntry - Can't parse shop product reward. " + reward.key + " is not a ResourceType (Which is fine for now).");
         }
     }
 }
        protected override void onPreShow([Optional, DefaultParameterValue(null)] object param)
        {
            this.m_inputParameters = (InputParameters)param;
            if (!string.IsNullOrEmpty(this.m_inputParameters.Headline))
            {
                this.PopupTitle.text = StringExtensions.ToUpperLoca(this.m_inputParameters.Headline);
            }
            else
            {
                this.PopupTitle.enabled = false;
            }
            if (!string.IsNullOrEmpty(this.m_inputParameters.Title))
            {
                this.DividerTitle.text = StringExtensions.ToUpperLoca(this.m_inputParameters.Title);
            }
            else
            {
                this.DividerTitle.enabled = false;
            }
            if (!string.IsNullOrEmpty(this.m_inputParameters.Message))
            {
                this.DescriptionText.enabled = true;
                this.DescriptionText.text    = this.m_inputParameters.Message;
            }
            else
            {
                this.DescriptionText.enabled = false;
            }
            if (this.m_inputParameters.DisposableBackgroundTexture != null)
            {
                this.RawBg.enabled = true;
                this.RawBg.texture = this.m_inputParameters.DisposableBackgroundTexture;
                float num     = ((float)this.m_inputParameters.DisposableBackgroundTexture.width) / ((float)this.m_inputParameters.DisposableBackgroundTexture.height);
                float newSize = Mathf.Clamp((float)(this.m_defaultWidth / num), (float)200f, (float)1880f);
                RectTransformExtensions.SetHeight(base.RectTm, newSize);
            }
            else
            {
                this.RawBg.enabled = false;
                RectTransformExtensions.SetHeight(base.RectTm, this.m_defaultHeight);
            }
            string flareProductIdForPromoSlot = Service.Binder.PromotionManager.GetFlareProductIdForPromoSlot(this.m_inputParameters.Slot);

            if (!string.IsNullOrEmpty(flareProductIdForPromoSlot))
            {
                ShopEntry shopEntryByFlareProductId = Service.Binder.ShopManager.GetShopEntryByFlareProductId(flareProductIdForPromoSlot);
                if (shopEntryByFlareProductId != null)
                {
                    this.m_purchaseController    = new ShopPurchaseController(shopEntryByFlareProductId, null, PathToShopType.Vendor, null, new Action <ShopEntry, PurchaseResult>(this.onPurchaseComplete));
                    this.PurchaseButtonText.text = this.m_purchaseController.getPriceText(1);
                    if (this.m_inputParameters.DisposableBackgroundTexture == null)
                    {
                        base.RewardsGrid.gameObject.SetActive(true);
                        List <Reward>  rewards = new List <Reward>();
                        PremiumProduct prod    = Service.Binder.ShopService.GetProduct(flareProductIdForPromoSlot);
                        foreach (ProductReward reward in ConfigShops.GetRewardsFromProduct(prod))
                        {
                            rewards.Add(ConfigShops.GetRewardFromProductReward(reward, prod));
                        }
                        base.InitRewardGrid(rewards);
                    }
                    else
                    {
                        base.RewardsGrid.gameObject.SetActive(false);
                    }
                }
            }
        }