private UXElement CreateDeployableUXElement(UXGrid grid, string uid, string assetName, int amount, IDeployableVO troop, BattleEntry battle) { UXElement result = grid.CloneTemplateItem(uid); UXSprite subElement = grid.GetSubElement <UXSprite>(uid, this.TroopCardIconName); ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(troop, subElement); Service.EventManager.SendEvent(EventId.ButtonCreated, new GeometryTag(troop, projectorConfig, battle)); projectorConfig.AnimPreference = AnimationPreference.NoAnimation; ProjectorUtils.GenerateProjector(projectorConfig); UXLabel subElement2 = grid.GetSubElement <UXLabel>(uid, this.TroopCardAmountName); subElement2.Text = LangUtils.GetMultiplierText(amount); UXLabel subElement3 = grid.GetSubElement <UXLabel>(uid, this.TroopCardLevelName); subElement3.Text = LangUtils.GetLevelText(troop.Lvl); FactionDecal.UpdateDeployableDecal(uid, grid, troop, this.TroopHeroDecalName); string text = null; if (troop is TroopTypeVO) { TroopTypeVO troop2 = troop as TroopTypeVO; Service.SkinController.GetApplicableSkin(troop2, battle.AttackerEquipment, out text); } int qualityInt; if (!string.IsNullOrEmpty(text)) { StaticDataController staticDataController = Service.StaticDataController; EquipmentVO equipmentVO = staticDataController.Get <EquipmentVO>(text); qualityInt = (int)equipmentVO.Quality; } else { qualityInt = Service.DeployableShardUnlockController.GetUpgradeQualityForDeployable(troop); } UXUtils.SetCardQuality(this, this.troopGrid, uid, qualityInt, this.TroopCardQualityName, this.TroopCardDefaultName); UXButton subElement4 = grid.GetSubElement <UXButton>(uid, this.TroopCardName); this.troopTooltipHelper.RegisterButtonTooltip(subElement4, troop, battle); return(result); }
private void AddExpendedItem(UXGrid expendedGrid, string entryItemUid, string troopUid, IUpgradeableVO troop, int count, int unitQuality, BattleEntry battleEntry) { if (expendedGrid.Count == 8) { return; } if (count <= 0) { return; } UXElement uXElement = expendedGrid.CloneTemplateItem(troopUid); uXElement.Root.name = UXUtils.FormatAppendedName(uXElement.Root.name, entryItemUid); UXLabel subElement = expendedGrid.GetSubElement <UXLabel>(troopUid, UXUtils.FormatAppendedName("LabelTroopsExpended", entryItemUid)); subElement.Text = ((count <= 0) ? string.Empty : this.lang.Get("TROOP_MULTIPLIER", new object[] { count })); UXLabel subElement2 = expendedGrid.GetSubElement <UXLabel>(troopUid, UXUtils.FormatAppendedName("LabelTroopLevel", entryItemUid)); subElement2.Text = LangUtils.GetLevelText(troop.Lvl); UXSprite subElement3 = expendedGrid.GetSubElement <UXSprite>(troopUid, UXUtils.FormatAppendedName("SpriteTroopsImage", entryItemUid)); ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(troop, subElement3); Service.EventManager.SendEvent(EventId.ButtonCreated, new GeometryTag(troop, projectorConfig, battleEntry)); UXUtils.SetupGeometryForIcon(subElement3, projectorConfig); string defaultCardName = UXUtils.FormatAppendedName("TroopsExpendBgDefault", entryItemUid); string cardName = UXUtils.FormatAppendedName("TroopsExpendBgQ{0}", entryItemUid); UXUtils.SetCardQuality(this, expendedGrid, troopUid, unitQuality, cardName, defaultCardName); FactionDecal.UpdateDeployableDecal(troopUid, entryItemUid, expendedGrid, (IDeployableVO)troop); UXButton subElement4 = expendedGrid.GetSubElement <UXButton>(troopUid, UXUtils.FormatAppendedName("TroopsExpendedCard", entryItemUid)); this.troopTooltipHelper.RegisterButtonTooltip(subElement4, troop, battleEntry); expendedGrid.AddItem(uXElement, troop.Order); }
private UXElement CreateDeployableUXElement(UXGrid grid, string uid, string assetName, int amount, IDeployableVO troop, BattleEntry battle) { UXElement result = grid.CloneTemplateItem(uid); UXSprite subElement = grid.GetSubElement <UXSprite>(uid, this.TroopCardIconName); ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(troop, subElement); Service.Get <EventManager>().SendEvent(EventId.ButtonCreated, new GeometryTag(troop, projectorConfig, battle)); projectorConfig.AnimPreference = AnimationPreference.NoAnimation; ProjectorUtils.GenerateProjector(projectorConfig); UXLabel subElement2 = grid.GetSubElement <UXLabel>(uid, this.TroopCardAmountName); subElement2.Text = LangUtils.GetMultiplierText(amount); UXLabel subElement3 = grid.GetSubElement <UXLabel>(uid, this.TroopCardLevelName); subElement3.Text = LangUtils.GetLevelText(troop.Lvl); FactionDecal.UpdateDeployableDecal(uid, grid, troop, this.TroopHeroDecalName); int upgradeQualityForDeployable = Service.Get <DeployableShardUnlockController>().GetUpgradeQualityForDeployable(troop); UXUtils.SetCardQuality(this, this.troopGrid, uid, upgradeQualityForDeployable, this.TroopCardQualityName, this.TroopCardDefaultName); UXButton subElement4 = grid.GetSubElement <UXButton>(uid, this.TroopCardName); this.troopTooltipHelper.RegisterButtonTooltip(subElement4, troop, battle); return(result); }
private void AddUpgradeableItemToTroopGrid(IDeployableVO nextTroop, IDeployableVO currentTroop, int sortOrder) { string uid = nextTroop.Uid; UXElement uXElement = this.troopGrid.CloneTemplateItem(uid); UXLabel subElement = this.troopGrid.GetSubElement <UXLabel>(uid, "LabelTroopLevel"); subElement.Text = LangUtils.GetLevelText(currentTroop.Lvl); UXElement subElement2 = this.troopGrid.GetSubElement <UXElement>(uid, "CardDefault"); UXElement subElement3 = this.troopGrid.GetSubElement <UXElement>(uid, "CardQuality"); string text = null; string text2 = null; bool flag = !nextTroop.PlayerFacing || nextTroop.Lvl == currentTroop.Lvl; bool flag2; if (flag) { flag2 = false; text = this.lang.Get("MAX_LEVEL", new object[0]); text2 = text; } else { flag2 = Service.UnlockController.CanDeployableBeUpgraded(currentTroop, nextTroop, out text, out text2); } this.troopGrid.GetSubElement <UXSprite>(uid, "SpriteDim").Visible = !flag2; this.troopGrid.GetSubElement <UXSprite>(uid, "SpriteIconLockedTroop").Visible = (!flag2 && !flag); UXSprite subElement4 = this.troopGrid.GetSubElement <UXSprite>(uid, "SpriteFragmentTroop"); bool flag3 = !string.IsNullOrEmpty(currentTroop.UpgradeShardUid); if (flag3) { subElement2.Visible = false; subElement3.Visible = true; subElement4.Visible = true; ShardVO shardVO = this.dataController.Get <ShardVO>(currentTroop.UpgradeShardUid); int quality = (int)shardVO.Quality; string name = string.Format("CardQ10", quality); UXElement optionalSubElement = this.troopGrid.GetOptionalSubElement <UXElement>(uid, name); if (optionalSubElement != null) { base.RevertToOriginalNameRecursively(optionalSubElement.Root, uid); optionalSubElement.Visible = true; } UXUtils.SetupFragmentIconSprite(subElement4, quality); IDeployableVO troopType = currentTroop; if (Service.UnlockController.IsMinLevelUnlocked(currentTroop)) { troopType = nextTroop; } this.SetupTroopShardProgressBar(uid, troopType, flag); } else { subElement4.Visible = false; subElement2.Visible = true; subElement3.Visible = false; } UXLabel subElement5 = this.troopGrid.GetSubElement <UXLabel>(uid, "LabelRequirement"); subElement5.Visible = !flag2; if (!flag2) { subElement5.Text = text2; } UXSlider subElement6 = this.troopGrid.GetSubElement <UXSlider>(uid, "pBarUpgradeTime"); subElement6.Visible = false; UXLabel subElement7 = this.troopGrid.GetSubElement <UXLabel>(uid, "LabelpBarUpgradeTime"); subElement7.Visible = false; UXSlider subElement8 = this.troopGrid.GetSubElement <UXSlider>(uid, "pBarUpgradeTimeQuality"); subElement8.Visible = false; UXLabel subElement9 = this.troopGrid.GetSubElement <UXLabel>(uid, "LabelpBarUpgradeTimeQuality"); subElement9.Visible = false; string text3 = "SpriteTroopItemImage"; if (flag3) { text3 += "Quality"; } UXSprite subElement10 = this.troopGrid.GetSubElement <UXSprite>(uid, text3); ProjectorConfig config = ProjectorUtils.GenerateGeometryConfig(nextTroop, subElement10, true); ProjectorUtils.GenerateProjector(config); FactionDecal.SetDeployableDecalVisibiliy(uid, this.troopGrid, false); TroopUpgradeTag troopUpgradeTag = new TroopUpgradeTag(nextTroop, flag2); troopUpgradeTag.IsMaxLevel = flag; troopUpgradeTag.RequirementText = text; troopUpgradeTag.ShortRequirementText = text2; UXButton subElement11 = this.troopGrid.GetSubElement <UXButton>(uid, "ButtonTroopItemCard"); subElement11.Tag = troopUpgradeTag; subElement11.OnClicked = new UXButtonClickedDelegate(this.OnTroopCardClicked); uXElement.Tag = troopUpgradeTag; this.troopGrid.AddItem(uXElement, sortOrder); }