Пример #1
0
        public ulong GetRemainingTimeSeconds(RemotePromotion promotion)
        {
            if (!promotion.State.Active)
            {
                return(0L);
            }
            long  gameTime  = Service.Binder.ServerTime.GameTime;
            ulong timestamp = promotion.State.Timestamp;

            if (timestamp > 0L)
            {
                long num3 = ((long)timestamp) - gameTime;
                if (num3 < 0L)
                {
                    this.ConsumePromotion(promotion, false);
                }
                return((ulong)num3);
            }
            if (promotion.timing == null)
            {
                return(0x7fffffffffffffffL);
            }
            if (gameTime < promotion.timing.start)
            {
                return(0L);
            }
            return(promotion.timing.end - ((ulong)gameTime));
        }
Пример #2
0
        public RemotePromotion GetPromotionForPromoSlot(string promoSlot)
        {
            List <RemotePromotion> promotions = Service.Binder.PromotionService.Promotions;

            if ((promotions != null) && (promotions.Count != 0))
            {
                foreach (RemotePromotion promotion in promotions)
                {
                    if ((this.GetRemainingTimeSeconds(promotion) != 0) && this.ValidatePlayerConditions(promotion))
                    {
                        this.CheckForPromotionGotActiveTrackingEvent(promotion);
                        if (promotion.PromotionType != EPromotionType.IapPlacement)
                        {
                            if (promoSlot.Equals(promotion.ParsedCustomParams.Placement))
                            {
                                return(promotion);
                            }
                        }
                        else
                        {
                            foreach (KeyValuePair <string, object> pair in promotion.customParams)
                            {
                                string str = RemotePromotion.FixPromoSlot(pair.Key);
                                if (promoSlot.Equals(str))
                                {
                                    return(promotion);
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }
Пример #3
0
 public void ConsumePromotion(RemotePromotion promotion, bool considerConsumeFlag)
 {
     if (!considerConsumeFlag || promotion.ParsedCustomParams.ConsumeOnAction)
     {
         promotion.State.Consumed = true;
         CmdSavePlayerDataToPersistentStorage.ExecuteStatic(GameLogic.Binder.GameState.Player);
     }
 }
Пример #4
0
 public void CheckForPromotionGotActiveTrackingEvent(RemotePromotion promotion)
 {
     if (promotion.State.Active && !promotion.State.ActivatedOnce)
     {
         promotion.State.ActivatedOnce = true;
         Service.Binder.EventBus.PromotionAction(promotion.promotionid, "Activate");
         CmdSavePlayerDataToPersistentStorage.ExecuteStatic(GameLogic.Binder.GameState.Player);
     }
 }
Пример #5
0
        public List <ProductReward> GetCosts(RemotePromotion promotion)
        {
            RewardParams parsedCustomParams = promotion.ParsedCustomParams as RewardParams;

            if (parsedCustomParams == null)
            {
                return(null);
            }
            return(parsedCustomParams.Costs);
        }
Пример #6
0
 public void GetEventPromotions(ref List <RemotePromotion> output)
 {
     for (int i = 0; i < Service.Binder.PromotionService.Promotions.Count; i++)
     {
         RemotePromotion promotion = Service.Binder.PromotionService.Promotions[i];
         if (((promotion.PromotionType == EPromotionType.Event) && promotion.State.Active) && this.ValidatePlayerConditions(promotion))
         {
             output.Add(promotion);
         }
     }
 }
Пример #7
0
 public RemotePromotion GetNextPromotionVisibleInTaskPanel()
 {
     for (int i = 0; i < Service.Binder.PromotionService.Promotions.Count; i++)
     {
         RemotePromotion promotion = Service.Binder.PromotionService.Promotions[i];
         if (((promotion.IsValid() && (this.GetRemainingTimeSeconds(promotion) > 0L)) && (this.ValidatePlayerConditions(promotion) && promotion.ParsedCustomParams.ShowInTaskPanel)) && !promotion.State.TaskpanelShown)
         {
             this.CheckForPromotionGotActiveTrackingEvent(promotion);
             return(promotion);
         }
     }
     return(null);
 }
Пример #8
0
 private void onPromotionsAvailable()
 {
     this.m_remotePromotionEvents.Clear();
     this.m_remotePromotions.Clear();
     Service.Binder.PromotionManager.GetEventPromotions(ref this.m_remotePromotions);
     for (int i = 0; i < this.m_remotePromotions.Count; i++)
     {
         RemotePromotion remotePromotion = this.m_remotePromotions[i];
         this.m_remotePromotionEvents.Add(remotePromotion.promotionid, new ConfigPromotionEvents.Event(remotePromotion));
     }
     IOUtil.SaveToPersistentStorage(JsonUtils.Serialize(this.m_remotePromotionEvents), "cached_remote_promotion_events.json", ConfigApp.PersistentStorageEncryptionEnabled, true);
     this.addDebugEvent();
     this.refresh();
 }
Пример #9
0
 public RemotePromotion GetPromotion(string id, [Optional, DefaultParameterValue(0)] EPromotionType type)
 {
     if (!string.IsNullOrEmpty(id))
     {
         for (int i = 0; i < Service.Binder.PromotionService.Promotions.Count; i++)
         {
             RemotePromotion promotion = Service.Binder.PromotionService.Promotions[i];
             if (((type == EPromotionType.Unknown) || (promotion.PromotionType == type)) && (promotion.promotionid == id))
             {
                 return(promotion);
             }
         }
     }
     return(null);
 }
Пример #10
0
        public List <Reward> GetRewards(RemotePromotion promotion)
        {
            RewardParams parsedCustomParams = promotion.ParsedCustomParams as RewardParams;

            if (parsedCustomParams == null)
            {
                return(null);
            }
            List <Reward> list = new List <Reward>();

            foreach (ProductReward reward in parsedCustomParams.Rewards)
            {
                Reward rewardFromProductReward = ConfigShops.GetRewardFromProductReward(reward, null);
                list.Add(rewardFromProductReward);
            }
            return(list);
        }
Пример #11
0
 public string GetSlotForPromotion(RemotePromotion promotion)
 {
     if (promotion.ParsedCustomParams.Placement != null)
     {
         return(promotion.ParsedCustomParams.Placement);
     }
     foreach (string str in ShopManager.ValidPromoSlots)
     {
         if (Service.Binder.PromotionManager.GetPromotionForPromoSlot(str) == promotion)
         {
             return(str);
         }
     }
     foreach (string str2 in ShopManager.ValidSecondaryPromoSlots)
     {
         if (Service.Binder.PromotionManager.GetPromotionForPromoSlot(str2) == promotion)
         {
             return(str2);
         }
     }
     return(null);
 }
Пример #12
0
        public string GetFlareProductIdForPromoSlot(string promoSlot)
        {
            List <RemotePromotion> promotions = Service.Binder.PromotionService.Promotions;

            if ((promotions != null) && (promotions.Count != 0))
            {
                foreach (RemotePromotion promotion in promotions)
                {
                    if ((promotion.PromotionType == EPromotionType.IapPlacement) && (this.GetRemainingTimeSeconds(promotion) != 0))
                    {
                        foreach (KeyValuePair <string, object> pair in promotion.customParams)
                        {
                            string str = RemotePromotion.FixPromoSlot(pair.Key);
                            if (promoSlot.Equals(str))
                            {
                                return(pair.Value.ToString());
                            }
                        }
                    }
                }
            }
            return(null);
        }