Exemple #1
0
        private void OnPurchaseSuccess(object cookie)
        {
            if (cookie == null)
            {
                return;
            }
            if (ProcessingScreen.IsShowing())
            {
                ProcessingScreen.Hide();
                this.animDelayTimerId = Service.ViewTimerManager.CreateViewTimer(0.4f, false, new TimerDelegate(this.OnPostBlockingTriggerAnimations), null);
            }
            int num = (int)cookie;
            int clientPredictionId = Service.ShardShopController.ClientPredictionId;

            if (num < clientPredictionId)
            {
                return;
            }
            this.predictedData = Service.ShardShopController.CurrentShopData.Copy();
            if (this.vto != null)
            {
                ShardShopViewTO shardShopViewTO = Service.ShardShopController.GenerateViewTO(this.vto.SlotIndex, Service.CurrentPlayer, this.predictedData);
                this.Render(shardShopViewTO, false);
            }
        }
Exemple #2
0
        public override ISerializable FromObject(object obj)
        {
            StaticDataController        staticDataController = Service.StaticDataController;
            Dictionary <string, object> dictionary           = obj as Dictionary <string, object>;

            this.ShopData = new ShardShopData();
            if (dictionary.ContainsKey("activeSeriesId"))
            {
                string text = dictionary["activeSeriesId"] as string;
                if (string.IsNullOrEmpty(text))
                {
                    Service.Logger.Error("Shard Shop Active Series not found!");
                    return(this);
                }
                this.ShopData.ActiveSeries = staticDataController.Get <ShardShopSeriesVO>(text);
            }
            if (dictionary.ContainsKey("shardOffers"))
            {
                Dictionary <string, object> dictionary2 = dictionary["shardOffers"] as Dictionary <string, object>;
                foreach (string current in dictionary2.Keys)
                {
                    CrateSupplyVO value = staticDataController.Get <CrateSupplyVO>(dictionary2[current] as string);
                    this.ShopData.ShardOffers.Add(current, value);
                }
            }
            if (dictionary.ContainsKey("shardShopData"))
            {
                Dictionary <string, object> dictionary3 = dictionary["shardShopData"] as Dictionary <string, object>;
                if (dictionary3.ContainsKey("seriesId"))
                {
                    this.ShopData.CurrentSeriesPeriod = (dictionary3["seriesId"] as string);
                }
                if (dictionary3.ContainsKey("offerExpiration"))
                {
                    this.ShopData.Expiration = Convert.ToUInt32(dictionary3["offerExpiration"]);
                }
                if (dictionary3.ContainsKey("offsetMinutes"))
                {
                    this.ShopData.OffsetMinutes = Convert.ToSingle(dictionary3["offsetMinutes"]);
                }
                for (int i = 0; i < 5; i++)
                {
                    string shardSlotId = GameUtils.GetShardSlotId(i);
                    if (dictionary3.ContainsKey(shardSlotId))
                    {
                        Dictionary <string, object> dictionary4 = dictionary3[shardSlotId] as Dictionary <string, object>;
                        if (dictionary4 != null)
                        {
                            foreach (string current2 in dictionary4.Keys)
                            {
                                this.ShopData.Purchases[i].Add(current2, Convert.ToInt32(dictionary4[current2]));
                            }
                        }
                    }
                }
            }
            return(this);
        }
Exemple #3
0
        public ShardShopViewModule(StoreScreen parent)
        {
            this.parent                      = parent;
            this.lang                        = Service.Lang;
            this.modal                       = parent.GetElement <UXElement>("ModalPurchase");
            this.modalAnimator               = this.modal.Root.GetComponent <Animator>();
            this.animDelayTimerId            = 0u;
            this.quantityCounter             = parent.GetElement <UXLabel>("LabelQuantityCounter");
            this.quantityFloatingCounter     = parent.GetElement <UXLabel>("LabelQuantityCounterFloater");
            this.iconHolder                  = parent.GetElement <UXElement>("WidgetFragPlaceholder");
            this.bodyText                    = parent.GetElement <UXLabel>("LabelBodyText");
            this.titleText                   = parent.GetElement <UXLabel>("LabelTitle");
            this.purchaseSingleLabel         = parent.GetElement <UXLabel>("LabelPurchase1");
            this.purchaseAllLabel            = parent.GetElement <UXLabel>("LabelPurchaseAll");
            this.purchaseSingleDescLabel     = parent.GetElement <UXLabel>("CostOptionPay1LabelDescription");
            this.purchaseAllDescLabel        = parent.GetElement <UXLabel>("CostOptionPayAllLabelDescription");
            this.purchaseSingleSprite        = parent.GetElement <UXSprite>("SpriteCurrencyPurchase1");
            this.purchaseAllSprite           = parent.GetElement <UXSprite>("SpritePurchaseAllIcon");
            this.closeModalBtn               = parent.GetElement <UXButton>("BtnModalClose");
            this.purchaseSingleBtn           = parent.GetElement <UXButton>("BtnPurchase1");
            this.purchaseAllBtn              = parent.GetElement <UXButton>("BtnPurchaseAll");
            this.returnBtn                   = parent.GetElement <UXButton>("BtnReturn");
            this.closeModalBtn.OnClicked     = new UXButtonClickedDelegate(this.OnCloseModalClicked);
            this.purchaseSingleBtn.OnClicked = new UXButtonClickedDelegate(this.OnPurchaseShardsClicked);
            this.purchaseAllBtn.OnClicked    = new UXButtonClickedDelegate(this.OnPurchaseShardsClicked);
            this.returnBtn.OnClicked         = new UXButtonClickedDelegate(this.OnCloseModalClicked);
            UXElement element = parent.GetElement <UXElement>("FragmentItemTemplate");

            this.icon = parent.CloneElement <UXElement>(element, "ModalIcon", this.iconHolder.Root);
            this.iconProgressLabel         = parent.GetElement <UXLabel>(UXUtils.FormatAppendedName("LabelFragProgress", "ModalIcon"));
            this.iconProgressMessage1      = parent.GetElement <UXLabel>(UXUtils.FormatAppendedName("LabelFragProgressMessage1", "ModalIcon"));
            this.iconProgressMessage1.Text = this.lang.Get("CRATE_REWARD_POPUP_PROGRESS_UPGRADE_SEQ1", new object[0]);
            this.iconProgressMessage2      = parent.GetElement <UXLabel>(UXUtils.FormatAppendedName("LabelFragProgressMessage2", "ModalIcon"));
            this.iconProgressMessage2.Text = this.lang.Get("CRATE_REWARD_POPUP_PROGRESS_UPGRADE_SEQ2", new object[0]);
            this.iconRequirement           = parent.GetElement <UXLabel>(UXUtils.FormatAppendedName("LabelFragmentRequirement", "ModalIcon"));
            this.iconSprite                = parent.GetElement <UXSprite>(UXUtils.FormatAppendedName("SpriteFragmentImage", "ModalIcon"));
            this.iconButtonCard            = parent.GetElement <UXButton>(UXUtils.FormatAppendedName("ButtonFragmentCard", "ModalIcon"));
            this.iconBaseShardProgressBar  = parent.GetElement <UXSlider>(UXUtils.FormatAppendedName("pBarFragmentCount", "ModalIcon"));
            this.iconDeltaShardProgressBar = parent.GetElement <UXSlider>(UXUtils.FormatAppendedName("pBarFragmentCountDelta", "ModalIcon"));
            this.iconAnimator              = this.iconButtonCard.Root.GetComponent <Animator>();
            this.icon.Visible              = false;
            Service.ShardShopController.ResetClientPredictionId();
            this.predictedData = Service.ShardShopController.CurrentShopData.Copy();
        }
Exemple #4
0
        public static CostVO CalculateCost(int slotIndex, int quantity, ShardShopData data)
        {
            Dictionary <string, int> dictionary = data.Purchases[slotIndex];
            ShardShopPoolVO          pool       = data.ActiveSeries.GetPool(slotIndex);
            int num = 0;

            foreach (int current in dictionary.Values)
            {
                num += current;
            }
            CostVO costVO = pool.GetCost(num);

            if (quantity > 1)
            {
                for (int i = 1; i < quantity; i++)
                {
                    CostVO cost = pool.GetCost(num + i);
                    costVO = CostUtils.Combine(costVO, cost);
                }
            }
            return(CostUtils.CombineCurrenciesForShards(costVO));
        }
Exemple #5
0
        public ShardShopViewTO GenerateViewTO(int index, CurrentPlayer player, ShardShopData data)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            int             playerHQLevel             = player.Map.FindHighestHqLevel();
            ShardShopViewTO shardShopViewTO           = new ShardShopViewTO();
            string          shardSlotId = GameUtils.GetShardSlotId(index);
            int             num         = 0;

            foreach (int current in data.Purchases[index].Values)
            {
                num += current;
            }
            int num2 = this.adjustedOfferQuantity[index] - num;

            shardShopViewTO.SlotIndex = index;
            shardShopViewTO.SupplyVO  = data.ShardOffers[shardSlotId];
            shardShopViewTO.RemainingShardsForSale = num2;
            if (num2 > 0)
            {
                shardShopViewTO.CostOfNextShard = ShardShopController.CalculateCost(index, 1, data);
                shardShopViewTO.CostOfAllShards = ShardShopController.CalculateCost(index, num2, data);
            }
            shardShopViewTO.CanAffordSingle       = CostUtils.HasRequiredCurrency(player, shardShopViewTO.CostOfNextShard);
            shardShopViewTO.CanAffordAll          = CostUtils.HasRequiredCurrency(player, shardShopViewTO.CostOfAllShards);
            shardShopViewTO.PlayerHQLevel         = playerHQLevel;
            shardShopViewTO.ItemName              = GameUtils.GetShardShopNameWithoutQuantity(shardShopViewTO.SupplyVO, staticDataController);
            shardShopViewTO.Quality               = GameUtils.GetShardQualityNumeric(shardShopViewTO.SupplyVO);
            shardShopViewTO.UpgradeShardsEarned   = GameUtils.GetUpgradeShardsOwned(shardShopViewTO.SupplyVO, player);
            shardShopViewTO.UpgradeShardsRequired = GameUtils.GetUpgradeShardsRequired(shardShopViewTO.SupplyVO, player, staticDataController);
            shardShopViewTO.State = "unlocked";
            SupplyType type = shardShopViewTO.SupplyVO.Type;

            if (this.adjustedOfferQuantity[index] < 1)
            {
                shardShopViewTO.State = "maxedOut";
            }
            else if (num2 < 1)
            {
                shardShopViewTO.State = "soldOut";
            }
            else if (type == SupplyType.Shard && !ArmoryUtils.PlayerHasArmory())
            {
                shardShopViewTO.State = "requiresArmory";
            }
            else if (type == SupplyType.ShardTroop)
            {
                ShardVO             shardVO             = staticDataController.Get <ShardVO>(shardShopViewTO.SupplyVO.RewardUid);
                TroopUpgradeCatalog troopUpgradeCatalog = Service.TroopUpgradeCatalog;
                TroopTypeVO         byLevel             = troopUpgradeCatalog.GetByLevel(shardVO.TargetGroupId, 1);
                if (byLevel != null && byLevel.Type == TroopType.Mercenary && !Service.BuildingLookupController.HasCantina())
                {
                    shardShopViewTO.State = "requiresCantina";
                }
            }
            if (type == SupplyType.Shard)
            {
                EquipmentUpgradeCatalog equipmentUpgradeCatalog  = Service.EquipmentUpgradeCatalog;
                EquipmentVO             currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(shardShopViewTO.SupplyVO.RewardUid);
                int shards = player.GetShards(shardShopViewTO.SupplyVO.RewardUid);
                int shardsRequiredForNextUpgrade = ArmoryUtils.GetShardsRequiredForNextUpgrade(player, equipmentUpgradeCatalog, currentEquipmentDataByID);
                shardShopViewTO.Upgradeable = (shards >= shardsRequiredForNextUpgrade && shardsRequiredForNextUpgrade > 0);
            }
            else if (type == SupplyType.ShardTroop || type == SupplyType.ShardSpecialAttack)
            {
                shardShopViewTO.Upgradeable = Service.DeployableShardUnlockController.IsShardDeployableReadyToUpgrade(shardShopViewTO.SupplyVO.RewardUid);
            }
            return(shardShopViewTO);
        }