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); } }
private void PredictNewPurchase(int quantityToPurchase, bool blocking) { ShardShopController shardShopController = Service.ShardShopController; if (this.predictedData.Purchases[this.vto.SlotIndex].ContainsKey("Temp")) { Dictionary <string, int> dictionary; (dictionary = this.predictedData.Purchases[this.vto.SlotIndex])["Temp"] = dictionary["Temp"] + quantityToPurchase; } else { this.predictedData.Purchases[this.vto.SlotIndex].Add("Temp", quantityToPurchase); } CurrentPlayer currentPlayer = Service.CurrentPlayer; ShardShopViewTO shardShopViewTO = shardShopController.GenerateViewTO(this.vto.SlotIndex, currentPlayer, this.predictedData); shardShopViewTO.UpgradeShardsEarned += quantityToPurchase; this.quantityFloatingCounter.Text = this.vto.RemainingShardsForSale.ToString(); this.modalAnimator.SetBool("BuyFragment", true); this.Render(shardShopViewTO, true); if (blocking) { ProcessingScreen.Show(); } else { this.ShowPurchaseFlourishAnimation(); } }
public void Show(ShardShopViewTO vto) { this.Render(vto, false); this.RegisterEvents(); this.modal.Visible = true; this.parent.CurrentBackDelegate = new UXButtonClickedDelegate(this.OnCloseModalClicked); this.parent.CurrentBackButton = this.closeModalBtn; }
public void Hide() { this.isProgressBarLerping = false; this.modal.Visible = false; this.UnregisterEvents(); Service.ViewTimeEngine.UnregisterFrameTimeObserver(this); this.CleanUpAnimDelayTimer(); this.vto = null; this.parent.SetupBackButtonDelegate(); Service.EventManager.SendEvent(EventId.ShardViewClosed, null); }
public void Render(ShardShopViewTO vto, bool shouldShowProgressLerp) { bool flag = this.vto == null || this.vto.SupplyVO != vto.SupplyVO; bool flag2 = this.vto != null && !this.vto.ValueEquals(vto); if (flag2) { this.previousShardsEarned = this.vto.UpgradeShardsEarned; } this.vto = vto; if (flag) { IGeometryVO iconVOFromCrateSupply = GameUtils.GetIconVOFromCrateSupply(vto.SupplyVO, vto.PlayerHQLevel); ProjectorConfig config = ProjectorUtils.GenerateGeometryConfig(iconVOFromCrateSupply, this.iconSprite); this.projector = ProjectorUtils.GenerateProjector(config); } int upgradeShardsEarned = vto.UpgradeShardsEarned; int upgradeShardsRequired = vto.UpgradeShardsRequired; this.quantityCounter.Text = vto.RemainingShardsForSale.ToString(); this.bodyText.Text = this.lang.Get("shard_shop_shards_remaining", new object[] { vto.ItemName }); this.purchaseSingleDescLabel.Text = this.lang.Get("shard_shop_buy_single", new object[0]); this.purchaseAllDescLabel.Text = this.lang.Get("shard_shop_buy_all", new object[0]); this.nextProgressBarValue = this.GetProgessBarValue(upgradeShardsEarned, upgradeShardsRequired); this.previousProgressBarValue = this.GetProgessBarValue(this.previousShardsEarned, upgradeShardsRequired); this.iconDeltaShardProgressBar.Value = this.nextProgressBarValue; if (!shouldShowProgressLerp) { this.isProgressBarLerping = false; this.iconProgressLabel.Text = upgradeShardsEarned + "/" + upgradeShardsRequired; this.iconBaseShardProgressBar.Value = this.nextProgressBarValue; } else if (flag2) { this.progressLerpTimer = 0f; this.isProgressBarLerping = true; this.iconProgressLabel.Text = this.previousShardsEarned + "/" + upgradeShardsRequired; this.iconBaseShardProgressBar.Value = this.previousProgressBarValue; Service.ViewTimeEngine.RegisterFrameTimeObserver(this); } SupplyType type = vto.SupplyVO.Type; if (type != SupplyType.Shard) { if (type == SupplyType.ShardTroop || type == SupplyType.ShardSpecialAttack) { this.titleText.Text = this.lang.Get("shard_shop_buy_unit_shards", new object[0]); } } else { this.titleText.Text = this.lang.Get("shard_shop_buy_equipment_shards", new object[0]); } if (vto.RemainingShardsForSale > 0) { UXUtils.SetupSingleResourceUI(vto.CostOfNextShard, this.purchaseSingleLabel, this.purchaseSingleSprite); UXUtils.SetupSingleResourceUI(vto.CostOfAllShards, this.purchaseAllLabel, this.purchaseAllSprite); } this.returnBtn.Visible = (vto.RemainingShardsForSale == 0); this.purchaseSingleBtn.Visible = (vto.RemainingShardsForSale > 0); this.purchaseAllBtn.Visible = (vto.RemainingShardsForSale > 0); this.parent.RevertToOriginalNameRecursively(this.icon.Root, "ModalIcon"); Service.Engine.StartCoroutine(this.SetAnimatorState()); }
public bool ValueEquals(ShardShopViewTO shardShopVto) { return(shardShopVto != null && this.CanAffordAll == shardShopVto.CanAffordAll && this.CanAffordSingle == shardShopVto.CanAffordSingle && !(this.ItemName != shardShopVto.ItemName) && this.Quality == shardShopVto.Quality && this.RemainingShardsForSale == shardShopVto.RemainingShardsForSale && this.SlotIndex == shardShopVto.SlotIndex && this.UpgradeShardsEarned == shardShopVto.UpgradeShardsEarned && this.UpgradeShardsRequired == shardShopVto.UpgradeShardsRequired && this.PlayerHQLevel == shardShopVto.PlayerHQLevel && !(this.State != shardShopVto.State) && this.Upgradeable == shardShopVto.Upgradeable); }