private int SortCrateListByExpiration(UXElement a, UXElement b) { PrizeInventoryItemTag prizeInventoryItemTag = (PrizeInventoryItemTag)a.Tag; CrateData crateData = this.cp.Prizes.Crates.Available[prizeInventoryItemTag.PrizeID]; PrizeInventoryItemTag prizeInventoryItemTag2 = (PrizeInventoryItemTag)b.Tag; CrateData crateData2 = this.cp.Prizes.Crates.Available[prizeInventoryItemTag2.PrizeID]; if (!crateData.DoesExpire && !crateData2.DoesExpire) { return(0); } if (!crateData.DoesExpire) { return(1); } if (!crateData2.DoesExpire) { return(-1); } int num = (int)(crateData.ExpiresTimeStamp - crateData2.ExpiresTimeStamp); if (num < 0) { return(-1); } if (num > 0) { return(1); } return(0); }
public void OnViewClockTime(float dt) { int i = 0; int count = this.itemGrid.Count; while (i < count) { PrizeInventoryItemTag prizeInventoryItemTag = (PrizeInventoryItemTag)this.itemGrid.GetItem(i).Tag; if (prizeInventoryItemTag.PrizeType == PrizeType.Crate) { CrateData crateData = this.cp.Prizes.Crates.Available[prizeInventoryItemTag.PrizeID]; if (crateData.DoesExpire) { if (crateData.ExpiresTimeStamp <= ServerTime.Time) { this.SetupCurTabElements(); return; } UXLabel subElement = this.itemGrid.GetSubElement <UXLabel>(prizeInventoryItemTag.PrizeID, "LabelItemExpiration"); UXUtils.SetCrateExpirationTimerLabel(crateData, subElement, this.lang); } } i++; } }
private void OnCrateInfoModalClosed(object result, object cookie) { if (cookie == null) { int i = 0; int count = this.itemGrid.Count; while (i < count) { UXElement item = this.itemGrid.GetItem(i); PrizeInventoryItemTag prizeInventoryItemTag = (PrizeInventoryItemTag)item.Tag; UXButton subElement = this.itemGrid.GetSubElement <UXButton>(prizeInventoryItemTag.PrizeID, "InventoryCard"); subElement.Enabled = true; i++; } return; } }
private void OnInfoButtonClicked(UXButton button) { PrizeInventoryItemTag prizeInventoryItemTag = button.Tag as PrizeInventoryItemTag; IUpgradeableVO finalUnitFromPrize = TimedEventPrizeUtils.GetFinalUnitFromPrize(prizeInventoryItemTag.PrizeType, prizeInventoryItemTag.PrizeID); if (finalUnitFromPrize != null) { SmartEntity availableTroopResearchLab = Service.BuildingLookupController.GetAvailableTroopResearchLab(); TroopUpgradeTag troopUpgradeTag = new TroopUpgradeTag(finalUnitFromPrize as IDeployableVO, true); bool showUpgradeControls = !string.IsNullOrEmpty(troopUpgradeTag.Troop.UpgradeShardUid); Service.ScreenController.AddScreen(new DeployableInfoScreen(troopUpgradeTag, null, showUpgradeControls, availableTroopResearchLab)); } else { prizeInventoryItemTag.MainElement.Visible = false; prizeInventoryItemTag.InfoLabel.Visible = true; } Service.EventManager.SendEvent(EventId.InfoButtonClicked, null); }
private void OnTileClicked(UXButton button) { PrizeInventoryItemTag prizeInventoryItemTag = button.Tag as PrizeInventoryItemTag; if (prizeInventoryItemTag.InfoLabel.Visible) { prizeInventoryItemTag.InfoLabel.Visible = false; prizeInventoryItemTag.MainElement.Visible = true; return; } if (prizeInventoryItemTag.PrizeType == PrizeType.None) { Service.Get <EventManager>().SendEvent(EventId.InventoryCrateStoreOpen, prizeInventoryItemTag.IconAssetName); Service.Get <ScreenController>().CloseAll(); GameUtils.OpenStoreTreasureTab(); return; } if (prizeInventoryItemTag.PrizeType == PrizeType.Crate) { button.Enabled = false; CrateData crateData = this.cp.Prizes.Crates.Available[prizeInventoryItemTag.PrizeID]; GameUtils.OpenInventoryCrateModal(crateData, new OnScreenModalResult(this.OnCrateInfoModalClosed)); Service.Get <EventManager>().SendEvent(EventId.InventoryCrateTapped, crateData.CrateId + "|" + crateData.UId); return; } int num = TimedEventPrizeUtils.TransferPrizeFromInventory(prizeInventoryItemTag.PrizeType, prizeInventoryItemTag.PrizeID); if (num > 0) { prizeInventoryItemTag.CountLabel.Text = string.Format("x{0}", new object[] { num }); } else if (num == 0) { this.itemGrid.RemoveItem(prizeInventoryItemTag.TileElement); base.DestroyElement(prizeInventoryItemTag.TileElement); this.itemGrid.RepositionItems(); } this.ToggleEmptyTabMessage(); }
public void OnViewClockTime(float dt) { int i = 0; int count = this.itemGrid.Count; while (i < count) { PrizeInventoryItemTag prizeInventoryItemTag = (PrizeInventoryItemTag)this.itemGrid.GetItem(i).Tag; if (prizeInventoryItemTag.PrizeType == PrizeType.Crate) { CrateData crateData = this.cp.Prizes.Crates.Available[prizeInventoryItemTag.PrizeID]; if (crateData.DoesExpire) { if (crateData.ExpiresTimeStamp <= ServerTime.Time) { this.SetupCurTabElements(); return; } } } i++; } }
private UXElement CreateInventoryGridItem(string id, PrizeType prizeType, string title, string description, int count, IGeometryVO vo, int quality) { PrizeInventoryItemTag prizeInventoryItemTag = new PrizeInventoryItemTag(); UXElement uXElement = this.itemGrid.CloneTemplateItem(id); prizeInventoryItemTag.TileElement = uXElement; prizeInventoryItemTag.PrizeID = id; prizeInventoryItemTag.PrizeType = prizeType; uXElement.Tag = prizeInventoryItemTag; this.SetupGridItemQuality(id, quality); prizeInventoryItemTag.MainElement = this.itemGrid.GetSubElement <UXElement>(id, "ItemInfo"); UXLabel subElement = this.itemGrid.GetSubElement <UXLabel>(id, "LabelName"); subElement.Text = title; UXButton subElement2 = this.itemGrid.GetSubElement <UXButton>(id, "BtnItemInfo"); prizeInventoryItemTag.InfoLabel = this.itemGrid.GetSubElement <UXLabel>(id, "LabelItemInfo"); if (!string.IsNullOrEmpty(description) && prizeType != PrizeType.None) { prizeInventoryItemTag.InfoLabel.Text = description; subElement2.Visible = true; subElement2.OnClicked = new UXButtonClickedDelegate(this.OnInfoButtonClicked); subElement2.Tag = prizeInventoryItemTag; } else { subElement2.Visible = false; } prizeInventoryItemTag.CountLabel = this.itemGrid.GetSubElement <UXLabel>(id, "LabelItemCount"); UXSprite subElement3 = this.itemGrid.GetSubElement <UXSprite>(id, "SpriteItemImage"); if (prizeType == PrizeType.None) { RewardUtils.SetCrateIcon(subElement3, (CrateVO)vo, AnimState.Idle); } else if (prizeType == PrizeType.Crate) { RewardUtils.SetCrateIcon(subElement3, (CrateVO)vo, AnimState.Closed); } else { RewardUtils.SetRewardIcon(subElement3, vo, AnimationPreference.NoAnimation); } prizeInventoryItemTag.IconAssetName = vo.IconAssetName; UXButton subElement4 = this.itemGrid.GetSubElement <UXButton>(id, "InventoryCard"); subElement4.OnClicked = new UXButtonClickedDelegate(this.OnTileClicked); subElement4.Tag = prizeInventoryItemTag; this.itemGrid.GetSubElement <UXElement>(id, "CountAndBuildTime").Visible = true; this.itemGrid.GetSubElement <UXElement>(id, "ContainerJewelNew").Visible = false; UXLabel subElement5 = this.itemGrid.GetSubElement <UXLabel>(id, "LabelItemExpiration"); UXLabel subElement6 = this.itemGrid.GetSubElement <UXLabel>(id, "LabelCurrencyAmount"); subElement6.Visible = false; if (prizeType == PrizeType.None) { prizeInventoryItemTag.CountLabel.Visible = false; subElement5.Visible = false; subElement6.Text = description; subElement6.Visible = true; } else if (prizeType == PrizeType.Crate) { prizeInventoryItemTag.CountLabel.Visible = false; CrateData crateData = this.cp.Prizes.Crates.Available[id]; subElement5.Visible = true; UXUtils.SetCrateExpirationTimerLabel(crateData, subElement5, this.lang); if (!string.IsNullOrEmpty(crateData.PlanetId)) { PlanetVO planetVO = Service.StaticDataController.Get <PlanetVO>(crateData.PlanetId); UXTexture subElement7 = this.itemGrid.GetSubElement <UXTexture>(id, "TexturePlanet"); subElement7.LoadTexture(planetVO.LeaderboardTileTexture); } if (this.crateTabLastViewedTime < crateData.ReceivedTimeStamp) { this.itemGrid.GetSubElement <UXElement>(id, "ContainerJewelNew").Visible = true; this.itemGrid.GetSubElement <UXLabel>(id, "LabelMessageCountNew").Text = this.lang.Get("CRATE_INVENTORY_CRATE_NEW_BADGE", new object[0]); } subElement4.Tag = prizeInventoryItemTag; } else { prizeInventoryItemTag.CountLabel.Text = string.Format("x{0}", count); prizeInventoryItemTag.CountLabel.Visible = true; subElement5.Visible = false; } this.itemGrid.GetSubElement <UXLabel>(id, "LabelItemInfo").Visible = false; this.itemGrid.GetSubElement <UXLabel>(id, "LabelItemRequirement").Visible = false; this.itemGrid.GetSubElement <UXSprite>(id, "SpriteItemTimeIcon").Visible = false; this.itemGrid.GetSubElement <UXLabel>(id, "LabelBuildTime").Visible = false; uXElement.Tag = prizeInventoryItemTag; return(uXElement); }