Exemple #1
0
        private void SetupIAPLinkedOffer(TargetedBundleVO currentOffer)
        {
            this.purchaseWithCurrencySprite.Visible      = false;
            this.purchaseWithCurrencyButtonLabel.Visible = false;
            this.purchaseIAPButtonLabel.Visible          = true;
            TargetedBundleController targetedBundleController = Service.TargetedBundleController;
            bool flag = false;

            if (currentOffer != null)
            {
                string text;
                string text2;
                flag = targetedBundleController.FindAvailableIAP(currentOffer, out text, out text2);
                if (flag && !string.IsNullOrEmpty(text))
                {
                    this.purchaseIAPButtonLabel.Text = this.lang.Get("TARGETED_BUNDLE_PURCHASE", new object[]
                    {
                        text2
                    });
                    this.purchaseButton.Tag = text;
                }
            }
            if (!flag)
            {
                this.purchaseButton.Visible         = false;
                this.purchaseIAPButtonLabel.Visible = false;
                Service.Logger.Error("No iap available for targeted bundle screen: " + currentOffer.Uid);
            }
        }
Exemple #2
0
        private void OnTargetedOfferPurchaseClicked(UXButton button)
        {
            TargetedBundleController targetedBundleController = Service.Get <TargetedBundleController>();

            targetedBundleController.MakeTargetedBundlePurchase(this.CurrentOffer, this.currentIapId);
            this.Close(null);
        }
Exemple #3
0
 public void OnViewClockTime(float dt)
 {
     if (this.ignoreExpirationAutoClose)
     {
         return;
     }
     if (this.crateData != null)
     {
         if (this.crateData.ExpiresTimeStamp <= ServerTime.Time)
         {
             this.OnCloseCrateInfoButtonClicked(null);
             return;
         }
     }
     else if (this.targetLEIVO != null)
     {
         if ((long)this.targetLEIVO.EndTime <= (long)((ulong)ServerTime.Time))
         {
             this.OnCloseCrateInfoButtonClicked(null);
             return;
         }
     }
     else if (this.ModalReason == CrateInfoReason.Reason_Targeted_Offer)
     {
         TargetedBundleController targetedBundleController = Service.Get <TargetedBundleController>();
         if (targetedBundleController.OfferExpiresAt <= ServerTime.Time)
         {
             this.OnCloseCrateInfoButtonClicked(null);
             return;
         }
     }
 }
Exemple #4
0
        private void InitExpirationLabel()
        {
            TargetedBundleController targetedBundleController = Service.Get <TargetedBundleController>();

            this.expirationLabel = base.GetElement <UXLabel>("LabelCrateExpireTimer");
            if (this.ModalReason == CrateInfoReason.Reason_Store_Buy && this.targetLEIVO != null)
            {
                UXUtils.SetLeiExpirationTimerLabel(this.targetLEIVO, this.expirationLabel, this.lang);
                Service.Get <ViewTimeEngine>().RegisterClockTimeObserver(this, 1f);
                return;
            }
            if (this.ModalReason == CrateInfoReason.Reason_Inventory_Open && this.crateData != null)
            {
                UXUtils.SetCrateExpirationTimerLabel(this.crateData, this.expirationLabel, this.lang);
                if (this.crateData.DoesExpire)
                {
                    Service.Get <ViewTimeEngine>().RegisterClockTimeObserver(this, 1f);
                    return;
                }
            }
            else
            {
                if (this.ModalReason == CrateInfoReason.Reason_Targeted_Offer)
                {
                    UXUtils.SetCrateTargetedOfferTimerLabel(targetedBundleController.OfferExpiresAt, this.expirationLabel, this.lang);
                    Service.Get <ViewTimeEngine>().RegisterClockTimeObserver(this, 1f);
                    return;
                }
                this.expirationLabel.Visible = false;
            }
        }
        private void OnConfirmButtonClicked(UXButton button)
        {
            TargetedBundleController targetedBundleController = Service.Get <TargetedBundleController>();

            targetedBundleController.LogTargetedBundleBI("purchase_complete", this.currentOffer);
            Service.Get <EventManager>().SendEvent(EventId.TargetedBundleRewardRedeemed, null);
            targetedBundleController.ResetOffer();
            this.Close(null);
        }
Exemple #6
0
        private void OnPurchaseButtonClicked(UXButton button)
        {
            TargetedBundleController targetedBundleController = Service.TargetedBundleController;
            object tag   = button.Tag;
            string iapId = null;

            if (tag != null)
            {
                iapId = button.Tag.ToString();
            }
            targetedBundleController.MakeTargetedBundlePurchase(this.currentOffer, iapId);
            this.Close(null);
        }
Exemple #7
0
        private void ReserveTargetBundleOnServer(string productId)
        {
            ReserveTargetedOfferIDRequest reserveTargetedOfferIDRequest = new ReserveTargetedOfferIDRequest();
            TargetedBundleController      targetedBundleController      = Service.TargetedBundleController;

            if (targetedBundleController.CurrentTargetedOffer != null)
            {
                reserveTargetedOfferIDRequest.PlayerId  = Service.CurrentPlayer.PlayerId;
                reserveTargetedOfferIDRequest.ProductId = productId;
                reserveTargetedOfferIDRequest.OfferId   = targetedBundleController.CurrentTargetedOffer.Uid;
                ReserveTargetedOfferCommand reserveTargetedOfferCommand = new ReserveTargetedOfferCommand(reserveTargetedOfferIDRequest);
                reserveTargetedOfferCommand.AddFailureCallback(new AbstractCommand <ReserveTargetedOfferIDRequest, DefaultResponse> .OnFailureCallback(this.OnFailure));
                Service.ServerAPI.Sync(reserveTargetedOfferCommand);
            }
        }
Exemple #8
0
        private void RefreshData(CurrentPlayer player)
        {
            Crittercism.SetUsername(player.PlayerId);
            SquadController squadController = Service.SquadController;

            if (squadController != null)
            {
                Squad currentSquad = squadController.StateManager.GetCurrentSquad();
                if (currentSquad != null)
                {
                    Crittercism.SetValue("guildId", currentSquad.SquadID);
                }
                else
                {
                    Crittercism.SetValue("guildId", string.Empty);
                }
            }
            Crittercism.SetValue("isPayer", (player.LastPaymentTime <= 0u) ? "False" : "True");
            Crittercism.SetValue("faction", player.Faction.ToString());
            if (player.AbTests != null)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (KeyValuePair <string, object> current in player.AbTests)
                {
                    stringBuilder.Append(current.Key);
                    stringBuilder.Append(",");
                }
                string value = stringBuilder.ToString();
                Crittercism.SetValue("ABtests", value);
            }
            Crittercism.SetValue("HQLevel", player.Map.FindHighestHqLevel().ToString());
            TargetedBundleController targetedBundleController = Service.TargetedBundleController;

            if (targetedBundleController != null)
            {
                string value2 = (targetedBundleController.CurrentTargetedOffer == null) ? "null" : targetedBundleController.CurrentTargetedOffer.Uid;
                Crittercism.SetValue("SPDAvailable", value2);
            }
            EventManager eventManager = Service.EventManager;

            eventManager.RegisterObserver(this, EventId.PlayerIdSet);
            eventManager.RegisterObserver(this, EventId.PlayerFactionChanged);
            eventManager.RegisterObserver(this, EventId.SquadUpdated);
            eventManager.RegisterObserver(this, EventId.MetaDataLoadEnd);
            eventManager.RegisterObserver(this, EventId.TargetedBundleContentPrepared);
        }
Exemple #9
0
        private void UpdateElements()
        {
            StaticDataController     staticDataController     = Service.StaticDataController;
            TargetedBundleController targetedBundleController = Service.TargetedBundleController;

            this.currentOffer = targetedBundleController.CurrentTargetedOffer;
            if (this.currentOffer != null)
            {
                UXLabel element = base.GetElement <UXLabel>("LabelTitle");
                element.Text = this.lang.Get(this.currentOffer.Title, new object[0]);
                UXLabel element2 = base.GetElement <UXLabel>("LabelDescription");
                element2.Text = this.lang.Get(this.currentOffer.Description, new object[0]);
                TextureVO optional = staticDataController.GetOptional <TextureVO>("gui_textures_promotional");
                if (optional != null)
                {
                    UXTexture element3 = base.GetElement <UXTexture>("TexturePromoArt");
                    element3.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_entry");
                if (optional != null)
                {
                    UXTexture element4 = base.GetElement <UXTexture>("TextureEnvironmentEntry");
                    element4.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_treads");
                if (optional != null)
                {
                    UXTexture element5 = base.GetElement <UXTexture>("TextureEnvironmentRight");
                    element5.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_treads");
                if (optional != null)
                {
                    UXTexture element6 = base.GetElement <UXTexture>("TextureEnvironmentLeft");
                    element6.LoadTexture(optional.AssetName);
                }
                optional = staticDataController.GetOptional <TextureVO>("targeted_bundle_dust");
                if (optional != null)
                {
                    UXTexture element7 = base.GetElement <UXTexture>("TextureEnvironmentDustRight");
                    element7.LoadTexture(optional.AssetName);
                    element7 = base.GetElement <UXTexture>("TextureEnvironmentDustLeft");
                    element7.LoadTexture(optional.AssetName);
                }
                int i     = 0;
                int count = this.currentOffer.RewardUIDs.Count;
                while (i < count)
                {
                    RewardVO rewardVO = staticDataController.Get <RewardVO>(this.currentOffer.RewardUIDs[i]);
                    if (!RewardUtils.SetupTargetedOfferCrateRewardDisplay(rewardVO, this.itemLabels[i], this.itemSprites[i]))
                    {
                        List <RewardComponentTag> rewardComponents = RewardUtils.GetRewardComponents(rewardVO);
                        int j      = 0;
                        int count2 = rewardComponents.Count;
                        while (j < count2)
                        {
                            RewardComponentTag rewardComponentTag = rewardComponents[j];
                            this.itemLabels[i].Text = this.lang.Get("AMOUNT_AND_NAME", new object[]
                            {
                                rewardComponentTag.RewardName,
                                rewardComponentTag.Quantity
                            });
                            RewardUtils.SetRewardIcon(this.itemSprites[i], rewardComponentTag.RewardGeometryConfig, AnimationPreference.AnimationAlways);
                            j++;
                        }
                    }
                    i++;
                }
                if (targetedBundleController.IsCurrencyCostOffer(this.currentOffer))
                {
                    this.SetupCurrencyCostOffer(this.currentOffer);
                }
                else
                {
                    this.SetupIAPLinkedOffer(this.currentOffer);
                }
                UXUtils.SetupAnimatedCharacter(this.characterSprite1, this.currentOffer.Character1Image, ref this.charGeometry1);
                UXUtils.SetupAnimatedCharacter(this.characterSprite2, this.currentOffer.Character2Image, ref this.charGeometry2);
                uint serverTime = Service.ServerAPI.ServerTime;
                this.timeRemaining   = (int)(targetedBundleController.OfferExpiresAt - serverTime);
                this.timerLabel.Text = this.lang.Get("expires_in", new object[]
                {
                    GameUtils.GetTimeLabelFromSeconds(this.timeRemaining)
                });
                this.valueLabel.Text = this.lang.Get("PERCENTAGE", new object[]
                {
                    this.currentOffer.Discount.ToString()
                });
                this.value2Label.Text = this.lang.Get("TARGETED_BUNDLE_DISCOUNT", new object[]
                {
                    this.currentOffer.Discount.ToString()
                });
            }
            else
            {
                Service.Logger.Error("No current offer available for targeted bundle screen");
            }
        }