private void SetupShardRewardItemElements(string itemUID, CrateSupplyVO crateSupply) { ShardVO shardVO = Service.Get <IDataController>().Get <ShardVO>(crateSupply.RewardUid); int quality = (int)shardVO.Quality; string name = string.Format("SpriteTroopImageBkgGridQ{0}", new object[] { quality }); this.rewardsGrid.GetSubElement <UXElement>(itemUID, name).Visible = false; UXSprite subElement = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteIconFragmentLootTable"); UXUtils.SetupFragmentIconSprite(subElement, quality); UXSprite subElement2 = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteRewardItemImage"); IDeployableVO deployableVOFromShard = Service.Get <DeployableShardUnlockController>().GetDeployableVOFromShard(shardVO); if (deployableVOFromShard == null) { Service.Get <StaRTSLogger>().Error("SetupShardRewardItemElements Unable to find deployable"); return; } ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(deployableVOFromShard, subElement2, true); projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred; GeometryProjector item = ProjectorUtils.GenerateProjector(projectorConfig); this.projectors.Add(item); this.SetupDeployableShardProgress(itemUID, shardVO); UXUtils.SetCardQuality(this, this.rewardsGrid, itemUID, quality, "RewardItemCardQ{0}"); }
public override void OnDestroyElement() { if (this.projector != null) { this.projector.Destroy(); this.projector = null; } if (this.observingClockViewTime) { this.observingClockViewTime = false; Service.ViewTimeEngine.UnregisterClockTimeObserver(this); } if (this.sliders != null) { for (int i = 0; i < 6; i++) { this.sliders[i] = null; } } if (this.storageItemGrid != null) { this.storageItemGrid.Clear(); this.storageItemGrid = null; } this.troopTooltipHelper.Destroy(); this.troopTooltipHelper = null; this.troopList = null; base.OnDestroyElement(); }
private void DestroyIconGeometry() { if (this.iconGeometry != null) { this.iconGeometry.Destroy(); this.iconGeometry = null; } }
protected virtual void InitImages() { IGeometryVO imageGeometryConfig = this.GetImageGeometryConfig(); UXSprite element = base.GetElement <UXSprite>((!this.useStorageGroup) ? "BldgImageFrame" : "BldgImageFrameStorage"); ProjectorConfig projectorConfig = ProjectorUtils.GenerateBuildingConfig(imageGeometryConfig as BuildingTypeVO, element); projectorConfig.AnimPreference = AnimationPreference.AnimationAlways; this.projector = ProjectorUtils.GenerateProjector(projectorConfig); base.GetElement <UXSprite>("SpriteSquadSymbol").Visible = false; }
public void CleanUp() { this.RenderTexture = null; this.Config = null; if (this.Projector != null) { this.Projector.Destroy(); } this.Projector = null; this.CrateSupply = null; }
public DeployableTroopControl(UXCheckbox troopCheckbox, UXLabel troopCountLabel, UXSprite dimmerSprite, UXElement optionalGlowSprite, UXElement optionalActivateFxSprite, GeometryProjector optionalGeometry, bool isHero, bool isStarship, string uid, UXElement equipmentFX) { this.IsHero = isHero; this.IsStarship = isStarship; this.DeployableUid = uid; this.TroopCheckbox = troopCheckbox; this.TroopCountLabel = troopCountLabel; this.AbilityState = HeroAbilityState.Dormant; this.cardDimmer = dimmerSprite; this.glowElement = optionalGlowSprite; this.abilityActivateFxSprite = optionalActivateFxSprite; this.geometry = optionalGeometry; this.EquipmentFX = equipmentFX; if (this.abilityActivateFxSprite != null) { this.abilityActivateFxSprite.Visible = false; } this.Enable(); if (this.EquipmentFX == null) { return; } StaticDataController staticDataController = Service.StaticDataController; if (this.IsEquipmentActiveOnDeployable(staticDataController, this.DeployableUid)) { EventManager eventManager = Service.EventManager; eventManager.RegisterObserver(this, EventId.WorldInTransitionComplete); eventManager.RegisterObserver(this, EventId.HoloCommScreenDestroyed, EventPriority.AfterDefault); this.observingStarshipEvents = this.IsStarship; this.observingTroopEquipmentEvents = !this.IsStarship; } if (this.IsHero) { EventManager eventManager2 = Service.EventManager; string ability = staticDataController.Get <TroopTypeVO>(this.DeployableUid).Ability; if (!string.IsNullOrEmpty(ability)) { TroopAbilityVO troopAbilityVO = staticDataController.Get <TroopAbilityVO>(ability); if (!troopAbilityVO.Auto) { this.totalCoolDownTime = (troopAbilityVO.CoolDownTime + troopAbilityVO.Duration) * 0.001f; eventManager2.RegisterObserver(this, EventId.HeroDeployed); eventManager2.RegisterObserver(this, EventId.HeroKilled); eventManager2.RegisterObserver(this, EventId.TroopAbilityDeactivate); eventManager2.RegisterObserver(this, EventId.TroopAbilityCoolDownComplete); this.observingHeroEvents = true; } } } }
public override void OnDestroyElement() { this.labelUpgradeTime = null; Service.EventManager.UnregisterObserver(this, EventId.ContractCompleted); this.DisableTimers(); if (this.equipmentImage != null) { this.equipmentImage.Destroy(); this.equipmentImage = null; } this.equipmentList = null; this.selectedEquipment = null; this.nextEquipmentVoUpgrade = null; base.OnDestroyElement(); }
public void SetIconAsset(IUpgradeableVO iconAsset) { if (this.iconSprite != null) { bool flag = iconAsset != null; this.iconSprite.Visible = flag; this.DestroyIconGeometry(); if (flag) { ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(iconAsset, this.iconSprite); Service.EventManager.SendEvent(EventId.ButtonCreated, new GeometryTag(iconAsset, projectorConfig, Service.CurrentPlayer.ActiveArmory)); projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred; projectorConfig.Sharpness = 4f; this.iconGeometry = ProjectorUtils.GenerateProjector(projectorConfig); } } }
public void Destroy() { this.isProgressBarLerping = false; this.UnregisterEvents(); Service.ViewTimeEngine.UnregisterFrameTimeObserver(this); this.CleanUpAnimDelayTimer(); if (this.projector != null) { this.projector.Destroy(); this.projector = null; } if (this.icon != null) { UnityEngine.Object.Destroy(this.icon.Root); this.icon = null; } }
private void SetupEquipmentShardRewardItemElements(string itemUID, CrateSupplyVO crateSupply) { EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(crateSupply.RewardUid); int quality = (int)currentEquipmentDataByID.Quality; string name = string.Format("SpriteTroopImageBkgGridQ{0}", quality); this.rewardsGrid.GetSubElement <UXElement>(itemUID, name).Visible = true; UXSprite subElement = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteIconFragmentLootTable"); UXUtils.SetupFragmentIconSprite(subElement, quality); this.SetupEquipmentShardProgress(itemUID, currentEquipmentDataByID); UXSprite subElement2 = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteRewardItemImage"); ProjectorConfig projectorConfig = ProjectorUtils.GenerateEquipmentConfig(currentEquipmentDataByID, subElement2, true); projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred; GeometryProjector item = ProjectorUtils.GenerateProjector(projectorConfig); this.projectors.Add(item); UXUtils.SetCardQuality(this, this.rewardsGrid, itemUID, quality, "RewardItemCardQ{0}"); }
private void Redraw() { StaticDataController staticDataController = Service.StaticDataController; CurrentPlayer currentPlayer = Service.CurrentPlayer; UXUtils.HideQualityCards(this, "TroopImage", "TroopImageQ{0}"); int quality = (int)this.selectedEquipment.Quality; base.GetElement <UXElement>(string.Format("TroopImageQ{0}", quality)).Visible = true; base.GetElement <UXElement>(string.Format("SpriteTroopImageBkgGridQ{0}", quality)).Visible = true; base.GetElement <UXElement>("TroopImage").Visible = false; int quality2 = (int)this.selectedEquipment.Quality; base.GetElement <UXLabel>(string.Format("LabelQualityQ{0}", quality2)).Text = LangUtils.GetShardQuality(this.selectedEquipment.Quality); UXSprite element = base.GetElement <UXSprite>(string.Format("SpriteTroopSelectedItemImageQ{0}", quality2)); ProjectorConfig projectorConfig = ProjectorUtils.GenerateEquipmentConfig(this.selectedEquipment, element, true); projectorConfig.AnimPreference = AnimationPreference.AnimationPreferred; this.equipmentImage = ProjectorUtils.GenerateProjector(projectorConfig); this.SetProgressBarElements(currentPlayer, quality2); base.SetupFragmentSprite(quality2); base.GetElement <UXLabel>("LabelTroopInfo").Text = this.lang.Get(this.selectedEquipment.EquipmentDescription, new object[0]); base.GetElement <UXLabel>(string.Format("LabelQuantityOwnQ{0}", quality2)).Visible = false; this.PopulateAvailablePlanetsPanel(staticDataController); this.SetUpUpgradeElements(false); base.GetElement <UXElement>("MovementSpeed").Visible = false; base.GetElement <UXElement>("Range").Visible = false; base.GetElement <UXElement>("UnitCapacity").Visible = false; base.GetElement <UXElement>("TrainingTime").Visible = false; base.GetElement <UXElement>("TrainingCost").Visible = false; base.GetElement <UXElement>("InfoRow3alt").Visible = false; base.GetElement <UXButton>("BtnFinish").Visible = false; base.GetElement <UXButton>("ButtonPrimaryAction").Visible = false; this.DisplayBarsForEquipmentBuffs(staticDataController); if (this.forResearchLab) { this.SetUpResearchLabScreenInfo(staticDataController, currentPlayer); } else if (this.forArmoryScreen) { this.SetUpArmoryScreenInfo(currentPlayer); } else { base.GetElement <UXButton>("BtnNormal").Visible = false; base.GetElement <UXLabel>("LabelRequirement").Visible = false; UXLabel element2 = base.GetElement <UXLabel>("DialogBldgUpgradeTitle"); this.SetTitleText(element2, "BUILDING_INFO", this.selectedEquipment.EquipmentName, this.selectedEquipment.Lvl); } for (int i = 0; i < 4; i++) { this.SetupLeftTableItem(i, null, null); } string affectedUnit = this.GetAffectedUnit(); if (affectedUnit != null) { this.SetupLeftTableItem(0, "EQUIPMENT_INFO_AFFECTED_UNIT", affectedUnit); } this.SetupLeftTableItem(1, "EQUIPMENT_INFO_CAPACITY", this.selectedEquipment.Size.ToString()); }
public BuildingInfoScreen(SmartEntity selectedBuilding, bool useUpgradeGroup) : base("gui_building", selectedBuilding) { this.useUpgradeGroup = useUpgradeGroup; this.projector = null; this.troopTooltipHelper = new TroopTooltipHelper(); }
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 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 static void SetupAnimatedCharacter(UXSprite charSprite, string imageName, ref GeometryProjector geom) { if (charSprite != null && !string.IsNullOrEmpty(imageName)) { StaticDataController staticDataController = Service.StaticDataController; TroopTypeVO vo = staticDataController.Get <TroopTypeVO>(imageName); if (geom == null) { ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(vo, charSprite); projectorConfig.AnimPreference = AnimationPreference.AnimationAlways; geom = ProjectorUtils.GenerateProjector(projectorConfig); } } }