private UXElement CreateTileWithPrizeInfo(string id, int count, PrizeType prizeType) { string title = null; string description = null; DeployableShardUnlockController deployableShardUnlockController = Service.DeployableShardUnlockController; IGeometryVO geometryVO = TimedEventPrizeUtils.GetFinalUnitFromPrize(prizeType, id); int quality = 0; switch (prizeType) { case PrizeType.Currency: title = this.lang.Get(id.ToUpper(), new object[0]); geometryVO = UXUtils.GetDefaultCurrencyIconVO(id); break; case PrizeType.Infantry: case PrizeType.Hero: case PrizeType.Vehicle: case PrizeType.Mercenary: { TroopTypeVO troopTypeVO = (TroopTypeVO)geometryVO; quality = deployableShardUnlockController.GetUpgradeQualityForDeployable(troopTypeVO); title = LangUtils.GetTroopDisplayName(troopTypeVO); description = LangUtils.GetTroopDescription(troopTypeVO); break; } case PrizeType.SpecialAttack: { SpecialAttackTypeVO specialAttackTypeVO = (SpecialAttackTypeVO)geometryVO; quality = deployableShardUnlockController.GetUpgradeQualityForDeployable(specialAttackTypeVO); title = LangUtils.GetStarshipDisplayName(specialAttackTypeVO); description = LangUtils.GetStarshipDescription(specialAttackTypeVO); break; } case PrizeType.Crate: { CrateData crateData = this.cp.Prizes.Crates.Available[id]; string crateDisplayName = LangUtils.GetCrateDisplayName(crateData.CrateId); title = this.lang.Get("CRATE_INVENTORY_CRATE_TITLE", new object[] { LangUtils.GetPlanetDisplayName(crateData.PlanetId), crateDisplayName }); geometryVO = Service.StaticDataController.Get <CrateVO>(crateData.CrateId); break; } } return(this.CreateInventoryGridItem(id, prizeType, title, description, count, geometryVO, quality)); }
public void GetFirstRewardAssetName(string rewardUid, ref RewardType type, out IGeometryVO config) { if (string.IsNullOrEmpty(rewardUid)) { config = null; return; } RewardVO rewardVO = this.sdc.Get <RewardVO>(rewardUid); if (rewardVO.BuildingUnlocks != null && rewardVO.BuildingUnlocks.Length > 0) { BuildingTypeVO buildingTypeVO = this.sdc.Get <BuildingTypeVO>(rewardVO.BuildingUnlocks[0]); type = RewardType.Building; config = buildingTypeVO; return; } if (rewardVO.TroopUnlocks != null && rewardVO.TroopUnlocks.Length > 0) { TroopTypeVO troopTypeVO = this.sdc.Get <TroopTypeVO>(rewardVO.TroopUnlocks[0]); type = RewardType.Troop; config = troopTypeVO; return; } if (rewardVO.TroopRewards != null && rewardVO.TroopRewards.Length > 0) { string[] array = rewardVO.TroopRewards[0].Split(new char[] { ':' }); if (array != null && array.Length > 0) { TroopTypeVO troopTypeVO = this.sdc.Get <TroopTypeVO>(array[0]); type = RewardType.Troop; config = troopTypeVO; return; } } if (rewardVO.HeroUnlocks != null && rewardVO.HeroUnlocks.Length > 0) { TroopTypeVO troopTypeVO2 = this.sdc.Get <TroopTypeVO>(rewardVO.HeroUnlocks[0]); type = RewardType.Troop; config = troopTypeVO2; return; } if (rewardVO.HeroRewards != null && rewardVO.HeroRewards.Length > 0) { string[] array2 = rewardVO.HeroRewards[0].Split(new char[] { ':' }); if (array2 != null && array2.Length > 0) { TroopTypeVO troopTypeVO2 = this.sdc.Get <TroopTypeVO>(array2[0]); type = RewardType.Troop; config = troopTypeVO2; return; } } if (rewardVO.SpecialAttackRewards != null && rewardVO.SpecialAttackRewards.Length > 0) { string[] array3 = rewardVO.SpecialAttackRewards[0].Split(new char[] { ':' }); if (array3 != null && array3.Length > 0) { SpecialAttackTypeVO specialAttackTypeVO = this.sdc.Get <SpecialAttackTypeVO>(array3[0]); type = RewardType.Troop; config = specialAttackTypeVO; return; } } if (rewardVO.SpecialAttackUnlocks != null && rewardVO.SpecialAttackUnlocks.Length > 0) { SpecialAttackTypeVO specialAttackTypeVO = this.sdc.Get <SpecialAttackTypeVO>(rewardVO.SpecialAttackUnlocks[0]); type = RewardType.Troop; config = specialAttackTypeVO; return; } if (rewardVO.CurrencyRewards != null && rewardVO.CurrencyRewards.Length > 0) { type = RewardType.Currency; config = null; string[] array4 = rewardVO.CurrencyRewards[0].Split(new char[] { ':' }); if (array4 != null && array4.Length > 0) { string text = array4[0]; if (!string.IsNullOrEmpty(text)) { config = UXUtils.GetDefaultCurrencyIconVO(text); } return; } } type = RewardType.Invalid; config = null; }
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); }