private void InitFeaturedRewardsGrid() { this.rewardsGrid = base.GetElement <UXGrid>("RewardGrid"); this.rewardsGrid.SetTemplateItem("RewardItemTemplate"); InventoryCrateRewardController inventoryCrateRewardController = Service.Get <InventoryCrateRewardController>(); List <PlanetLootEntryVO> featuredLootEntriesForPlanet = inventoryCrateRewardController.GetFeaturedLootEntriesForPlanet(this.currentPlanet); bool flag = false; int i = 0; int count = featuredLootEntriesForPlanet.Count; while (i < count) { this.AddFeaturedRewardItemToGrid(featuredLootEntriesForPlanet[i], i); if (this.DoesLootEntryHaveCountdown(featuredLootEntriesForPlanet[i])) { flag = true; } i++; } this.rewardsGrid.RepositionItemsFrameDelayed(new UXDragDelegate(this.RewardsGridRepositionComplete)); if (flag) { Service.Get <ViewTimeEngine>().RegisterClockTimeObserver(this, 1f); } }
private void UpdateRewardUI(CrateFlyoutItemVO crateFlyoutItemVO) { IDataController dataController = Service.Get <IDataController>(); InventoryCrateRewardController inventoryCrateRewardController = Service.Get <InventoryCrateRewardController>(); string crateSupplyUid = crateFlyoutItemVO.CrateSupplyUid; CrateSupplyVO optional = dataController.GetOptional <CrateSupplyVO>(crateSupplyUid); if (optional != null) { base.GetElement <UXElement>("RewardItemDefault").Visible = false; for (int i = 1; i <= 3; i++) { base.GetElement <UXElement>(string.Format("RewardItemCardQ{0}", new object[] { i })).Visible = false; } if (optional.Type == SupplyType.ShardTroop || optional.Type == SupplyType.ShardSpecialAttack) { ShardVO optional2 = Service.Get <IDataController>().GetOptional <ShardVO>(optional.RewardUid); int quality = (int)optional2.Quality; base.GetElement <UXElement>(string.Format("RewardItemCardQ{0}", new object[] { quality })).Visible = true; base.GetElement <UXElement>(string.Format("SpriteTroopImageBkgGridQ{0}", new object[] { quality })).Visible = false; } else if (optional.Type == SupplyType.Shard) { EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(optional.RewardUid); int quality2 = (int)currentEquipmentDataByID.Quality; base.GetElement <UXElement>(string.Format("RewardItemCardQ{0}", new object[] { quality2 })).Visible = true; base.GetElement <UXElement>(string.Format("SpriteTroopImageBkgGridQ{0}", new object[] { quality2 })).Visible = true; } else if (optional.Type == SupplyType.Troop || optional.Type == SupplyType.Hero || optional.Type == SupplyType.SpecialAttack) { int upgradeQualityForDeployableUID = Service.Get <DeployableShardUnlockController>().GetUpgradeQualityForDeployableUID(optional.RewardUid); if (upgradeQualityForDeployableUID > 0) { base.GetElement <UXElement>(string.Format("RewardItemCardQ{0}", new object[] { upgradeQualityForDeployableUID })).Visible = true; base.GetElement <UXElement>(string.Format("SpriteTroopImageBkgGridQ{0}", new object[] { upgradeQualityForDeployableUID })).Visible = false; } } else { base.GetElement <UXElement>("RewardItemDefault").Visible = true; } IGeometryVO iconVOFromCrateSupply = GameUtils.GetIconVOFromCrateSupply(optional, this.hqLevel); if (iconVOFromCrateSupply != null) { ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(iconVOFromCrateSupply, this.spriteRewardImage, true); projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred; ProjectorUtils.GenerateProjector(projectorConfig); } else { Service.Get <StaRTSLogger>().ErrorFormat("CrateInfoModalScreen: Could not generate geometry for crate supply {0}", new object[] { optional.Uid }); } this.labelRewardChance.Text = this.lang.Get(crateFlyoutItemVO.DetailChanceString, new object[0]); this.labelRewardName.Text = this.lang.Get(crateFlyoutItemVO.DetailDescString, new object[0]); string[] listIcons = crateFlyoutItemVO.ListIcons; if (listIcons != null && listIcons.Length != 0) { this.spriteRewardIcon.SpriteName = listIcons[listIcons.Length - 1]; } else { this.spriteRewardIcon.Visible = false; } string detailTypeStringId = crateFlyoutItemVO.DetailTypeStringId; if (!string.IsNullOrEmpty(detailTypeStringId)) { this.labelRewardType.Visible = true; string text = this.lang.Get(detailTypeStringId, new object[0]); this.labelRewardType.Text = text; } else { this.labelRewardType.Visible = false; } int rewardAmount = inventoryCrateRewardController.GetRewardAmount(optional, this.hqLevel); string text2 = this.lang.ThousandsSeparated(rewardAmount); string quantityString = crateFlyoutItemVO.QuantityString; if (!string.IsNullOrEmpty(quantityString)) { this.labelRewardAmt.Text = this.lang.Get(quantityString, new object[] { text2 }); } else if (rewardAmount > 1) { this.labelRewardAmt.Text = this.lang.Get("lcfly_quant", new object[] { text2 }); } else { this.labelRewardAmt.Visible = false; } UXSprite element = base.GetElement <UXSprite>("SpriteLockIcon"); UXSprite element2 = base.GetElement <UXSprite>("SpriteRewardDim"); UXLabel element3 = base.GetElement <UXLabel>("LabelEquipmentRequirement"); element.Visible = false; element2.Visible = false; element3.Visible = false; bool flag = crateFlyoutItemVO.ReqArmory && !ArmoryUtils.PlayerHasArmory(); if (flag) { element2.Visible = true; element.Visible = true; element3.Visible = true; element3.Text = this.lang.Get("EQUIPMENT_ARMORY_REQUIRED", new object[0]); } this.UpdateRowHighlight(crateFlyoutItemVO.Uid, true); return; } Service.Get <StaRTSLogger>().ErrorFormat("CrateInfoModalScreen: Could not find crate supply {0} for crate flyout {1}", new object[] { crateSupplyUid, crateFlyoutItemVO.Uid }); }
private void AddFeaturedRewardItemToGrid(PlanetLootEntryVO lootEntry, int order) { IDataController dataController = Service.Get <IDataController>(); InventoryCrateRewardController inventoryCrateRewardController = Service.Get <InventoryCrateRewardController>(); Lang lang = Service.Get <Lang>(); CrateSupplyVO optional = dataController.GetOptional <CrateSupplyVO>(lootEntry.SupplyDataUid); if (optional == null) { Service.Get <StaRTSLogger>().ErrorFormat("Couldn't find CrateSupplyVO: {0} specified in PlanetLootEntryVO: {1}", new object[] { lootEntry.SupplyDataUid, lootEntry.Uid }); return; } string uid = lootEntry.Uid; UXElement uXElement = this.rewardsGrid.CloneTemplateItem(uid); uXElement.Tag = lootEntry; UXLabel subElement = this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelRewardName"); subElement.Text = inventoryCrateRewardController.GetCrateSupplyRewardName(optional); UXUtils.ClampUILabelWidth(subElement, 200, 0); UXLabel subElement2 = this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelGate"); subElement2.Text = string.Empty; if (!string.IsNullOrEmpty(lootEntry.NotesString)) { subElement2.Text = lang.Get(lootEntry.NotesString, new object[0]); UXUtils.ClampUILabelWidth(subElement2, 200, 0); } for (int i = 1; i <= 3; i++) { string name = string.Format("RewardItemCardQ{0}", new object[] { i }); this.rewardsGrid.GetSubElement <UXElement>(uid, name).Visible = false; } this.rewardsGrid.GetSubElement <UXElement>(uid, "RewardItemDefault").Visible = false; this.rewardsGrid.GetSubElement <UXElement>(uid, "pBarRewardItemFrag").Visible = false; this.rewardsGrid.GetSubElement <UXElement>(uid, "IconUpgrade").Visible = false; UXLabel subElement3 = this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelRewardTypeLootTimer"); UXUtils.ClampUILabelWidth(subElement3, 200, 0); bool flag = this.DoesLootEntryHaveCountdown(lootEntry); subElement3.Visible = flag; if (flag) { this.UpdateTimeRemainingLabel(lootEntry); } UXButton subElement4 = this.rewardsGrid.GetSubElement <UXButton>(uid, "BtnRewardInfo"); UXButton subElement5 = this.rewardsGrid.GetSubElement <UXButton>(uid, "BtnRewardItemCard"); subElement5.InitTweenComponent(); subElement4.Visible = false; if (optional.Type == SupplyType.Hero || optional.Type == SupplyType.Troop || optional.Type == SupplyType.SpecialAttack || optional.Type == SupplyType.Shard || optional.Type == SupplyType.ShardTroop || optional.Type == SupplyType.ShardSpecialAttack) { subElement4.Visible = true; subElement4.Tag = optional; subElement4.OnClicked = new UXButtonClickedDelegate(this.OnInfoButtonClicked); subElement5.Tag = optional; subElement5.OnClicked = new UXButtonClickedDelegate(this.OnInfoButtonClicked); } else { subElement5.DisablePlayTween(); } UXLabel subElement6 = this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelRewardTypeLootTable"); subElement6.Visible = true; this.rewardsGrid.GetSubElement <UXSprite>(uid, "SpriteIconFragmentLootTable").Visible = false; if (optional.Type == SupplyType.ShardTroop || optional.Type == SupplyType.ShardSpecialAttack) { this.SetupShardRewardItemElements(uid, optional); } else if (optional.Type == SupplyType.Shard) { this.SetupEquipmentShardRewardItemElements(uid, optional); } else { this.rewardsGrid.GetSubElement <UXElement>(uid, "RewardItemDefault").Visible = true; this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelFragProgress").Text = string.Empty; UXSprite subElement7 = this.rewardsGrid.GetSubElement <UXSprite>(uid, "SpriteRewardItemImage"); IGeometryVO geometryVO = null; if (optional.Type == SupplyType.Currency) { subElement6.Visible = false; geometryVO = UXUtils.GetDefaultCurrencyIconVO(optional.RewardUid); } else if (optional.Type == SupplyType.Hero || optional.Type == SupplyType.Troop) { geometryVO = dataController.Get <TroopTypeVO>(optional.RewardUid); } else if (optional.Type == SupplyType.SpecialAttack) { geometryVO = dataController.Get <SpecialAttackTypeVO>(optional.RewardUid); } if (geometryVO != null) { ProjectorConfig config = ProjectorUtils.GenerateGeometryConfig(geometryVO, subElement7, false); GeometryProjector item = ProjectorUtils.GenerateProjector(config); this.projectors.Add(item); } } this.SetupLockedRewardItemElements(uid, lootEntry); if (subElement6.Visible) { string typeStringID = lootEntry.TypeStringID; if (!string.IsNullOrEmpty(typeStringID)) { subElement6.Visible = true; subElement6.Text = lang.Get(typeStringID, new object[0]); } else { subElement6.Visible = false; } } subElement6.InitTweenComponent(); subElement3.InitTweenComponent(); if (flag && subElement6.Visible) { subElement6.EnablePlayTween(); subElement3.EnablePlayTween(); } else { subElement6.ResetPlayTweenTarget(); subElement3.ResetPlayTweenTarget(); subElement6.TextColor = Color.white; subElement3.TextColor = Color.white; } this.rewardsGrid.AddItem(uXElement, order); }
public static void TrySetupConflictItemRewardView(TournamentRewardsVO rewardGroup, UXLabel prizeLabel, UXSprite iconSprite, UXSprite crateSprite, UXElement basicElement, UXElement advancedElement, UXElement eliteElement, UXLabel crateCountLabel, UXSprite dataFragIcon, UXLabel optionalUnitName) { IDataController dataController = Service.Get <IDataController>(); CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); string text = string.Empty; FactionType faction = currentPlayer.Faction; if (faction != FactionType.Empire) { if (faction == FactionType.Rebel) { text = rewardGroup.RebelGuaranteedReward; } } else { text = rewardGroup.EmpireGuaranteedReward; } CrateSupplyVO optional = dataController.GetOptional <CrateSupplyVO>(text); Lang lang = Service.Get <Lang>(); if (optional != null) { UXUtils.TrySetupItemQualityView(optional, basicElement, advancedElement, eliteElement, null); int num = currentPlayer.Map.FindHighestHqLevel(); IGeometryVO iconVOFromCrateSupply = GameUtils.GetIconVOFromCrateSupply(optional, num); if (iconVOFromCrateSupply != null) { ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(iconVOFromCrateSupply, iconSprite, true); projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred; ProjectorUtils.GenerateProjector(projectorConfig); } else { Service.Get <StaRTSLogger>().ErrorFormat("Could not generate geometry for crate supply {0}", new object[] { optional.Uid }); } if (iconVOFromCrateSupply != null) { int shardQualityNumeric = GameUtils.GetShardQualityNumeric(optional); if (shardQualityNumeric > -1) { dataFragIcon.SpriteName = string.Format("icoDataFragQ{0}", new object[] { shardQualityNumeric }); dataFragIcon.Visible = true; } else { dataFragIcon.Visible = false; } } InventoryCrateRewardController inventoryCrateRewardController = Service.Get <InventoryCrateRewardController>(); int rewardAmount = inventoryCrateRewardController.GetRewardAmount(optional, num); if (rewardAmount > 1) { string text2 = lang.ThousandsSeparated(rewardAmount); prizeLabel.Text = lang.Get("CONFLICT_PRIZE_CRATE_MULTIPLIER", new object[] { text2 }); } else { prizeLabel.Visible = false; } if (optionalUnitName != null) { optionalUnitName.Text = inventoryCrateRewardController.GetCrateSupplyRewardName(optional); } } else { Service.Get <StaRTSLogger>().ErrorFormat("Could not find crate supply {0} for faction {1}", new object[] { text, currentPlayer.Faction }); } if (crateCountLabel != null) { crateCountLabel.Visible = false; } string[] crateRewardIds = rewardGroup.CrateRewardIds; CrateVO crateVO = null; if (crateRewardIds != null) { if (crateRewardIds.Length != 0) { crateVO = dataController.GetOptional <CrateVO>(rewardGroup.CrateRewardIds[0]); } if (crateCountLabel != null && crateRewardIds.Length > 1) { crateCountLabel.Visible = true; crateCountLabel.Text = lang.Get("CONFLICT_PRIZE_CRATE_MULTIPLIER", new object[] { crateRewardIds.Length }); } } if (crateVO != null) { RewardUtils.SetCrateIcon(crateSprite, crateVO, AnimState.Idle); return; } Service.Get <StaRTSLogger>().ErrorFormat("Missing crate reward meta data for tournament reward:{0}", new object[] { rewardGroup.Uid }); }