예제 #1
0
    public void SelectBanner()
    {
        displayPromoIndex = promos.Count == 0 ? 0 : displayPromoIndex % promos.Count;
        activePromo       = promos.Count == 0 ? UB_PromoDisplay.EMPTY_PROMO : promos[displayPromoIndex];
        AdjustSlotDisplay(displayPromoIndex);

        ViewSaleBtn.SetActive(!string.IsNullOrEmpty(PF_GameData.GetEventSaleStore(activePromo.EventKey)));
        PlayEventBtn.SetActive(activePromo.linkedAd == null && PF_GameData.GetEventAssociatedLevels(activePromo.EventKey).Count > 0);
        WatchAdBtn.SetActive(activePromo.linkedAd != null);

        if (activePromo.EventKey != null) // Event Type
        {
            selectedDesc.text  = activePromo.Description;
            selectedTitle.text = activePromo.Title;
        }
        else if (activePromo.linkedAd != null)  // Ad Type
        {
            var qtyString = string.Format("{0}", activePromo.linkedAd.Details.PlacementViewsRemaining == null ? "UNLIMITED rewarded ads." : activePromo.linkedAd.Details.PlacementViewsRemaining + " more rewarded ads.");
            selectedDesc.text  = activePromo.linkedAd.Details.RewardDescription + " You may watch " + qtyString;
            selectedTitle.text = activePromo.linkedAd.Details.RewardName;
        }
        else
        {
            selectedDesc.text  = GlobalStrings.NO_EVENTS_MSG;
            selectedTitle.text = "";
        }

        if (activePromo.assets.Banner != null)
        {
            PromoBanner.overrideSprite = Sprite.Create(activePromo.assets.Banner, new Rect(0, 0, activePromo.assets.Banner.width, activePromo.assets.Banner.height), new Vector2(0.5f, 0.5f));
        }
    }
    public void SelectBanner(UB_PromoDisplay newPromo, int index)
    {
        activePromo = newPromo;
        AdjustSlotDisplay(index);

        PlayEventBtn.SetActive(activePromo.linkedEvent != null);
        ViewSaleBtn.SetActive(activePromo.linkedSale != null || (activePromo.linkedEvent != null && !string.IsNullOrEmpty(activePromo.linkedEvent.StoreToUse)));

        if (activePromo.linkedSale != null) // Sale Type
        {
            selectedDesc.text  = activePromo.linkedSale.SaleDescription;
            selectedTitle.text = activePromo.linkedSale.SaleName;
        }
        else if (activePromo.linkedEvent != null) // Event Type
        {
            selectedDesc.text  = activePromo.linkedEvent.EventDescription;
            selectedTitle.text = activePromo.linkedEvent.EventName;
        }
        else
        {
            selectedDesc.text  = GlobalStrings.NO_EVENTS_MSG;
            selectedTitle.text = "";
        }

        if (activePromo.assets.Banner != null)
        {
            PromoBanner.sprite = Sprite.Create(activePromo.assets.Banner, new Rect(0, 0, activePromo.assets.Banner.width, activePromo.assets.Banner.height), new Vector2(0.5f, 0.5f));
        }
        else
        {
            PromoBanner.sprite = null;
        }
    }