private void SetupDeployableShardProgress(string itemUID, ShardVO shard) { CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); TroopUpgradeCatalog troopUpgradeCatalog = Service.Get <TroopUpgradeCatalog>(); StarshipUpgradeCatalog starshipUpgradeCatalog = Service.Get <StarshipUpgradeCatalog>(); UXSlider subElement = this.rewardsGrid.GetSubElement <UXSlider>(itemUID, "pBarRewardItemFrag"); UXSprite subElement2 = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteRewardItempBarFrag"); subElement.Visible = true; UXLabel subElement3 = this.rewardsGrid.GetSubElement <UXLabel>(itemUID, "LabelFragProgress"); UXElement subElement4 = this.rewardsGrid.GetSubElement <UXElement>(itemUID, "IconUpgrade"); IDeployableVO deployableVO; IDeployableVO byLevel; if (shard.TargetType == "specialAttack") { int nextLevel = currentPlayer.UnlockedLevels.Starships.GetNextLevel(shard.TargetGroupId); deployableVO = starshipUpgradeCatalog.GetByLevel(shard.TargetGroupId, nextLevel); byLevel = starshipUpgradeCatalog.GetByLevel(shard.TargetGroupId, nextLevel - 1); } else { int nextLevel = currentPlayer.UnlockedLevels.Troops.GetNextLevel(shard.TargetGroupId); deployableVO = troopUpgradeCatalog.GetByLevel(shard.TargetGroupId, nextLevel); byLevel = troopUpgradeCatalog.GetByLevel(shard.TargetGroupId, nextLevel - 1); } if (deployableVO == null) { subElement3.Text = this.lang.Get("MAX_LEVEL", new object[0]); subElement.Value = 1f; return; } bool flag = Service.Get <UnlockController>().IsMinLevelUnlocked(deployableVO); if (!flag) { deployableVO = byLevel; } int shardAmount = Service.Get <DeployableShardUnlockController>().GetShardAmount(deployableVO.UpgradeShardUid); int upgradeShardCount = deployableVO.UpgradeShardCount; subElement3.Text = this.lang.Get("FRACTION", new object[] { shardAmount, upgradeShardCount }); if (upgradeShardCount == 0) { Service.Get <StaRTSLogger>().ErrorFormat("CMS Error: Shards required for {0} is zero", new object[] { deployableVO.Uid }); return; } float sliderValue = (float)shardAmount / (float)upgradeShardCount; UXUtils.SetShardProgressBarValue(subElement, subElement2, sliderValue); subElement4.Visible = (flag && shardAmount >= upgradeShardCount); }
private void HandlePBarValueChange(float value, bool showCompleteLabels) { UXUtils.SetShardProgressBarValue(this.pBarRewardTop, this.spriteRewardTopPBar, value); Color color = this.spriteRewardTopPBar.Color; color.a *= 0.5f; this.spriteRewardBottomPBar.Color = color; if (value >= 1f & showCompleteLabels) { this.ShowUpgradeLabels(); return; } this.HideUpgradeLabels(); }
private void SetupEquipmentShardProgress(string itemUID, EquipmentVO eqp) { CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); UXSlider subElement = this.rewardsGrid.GetSubElement <UXSlider>(itemUID, "pBarRewardItemFrag"); UXSprite subElement2 = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteRewardItempBarFrag"); subElement.Visible = true; UXLabel subElement3 = this.rewardsGrid.GetSubElement <UXLabel>(itemUID, "LabelFragProgress"); UXElement subElement4 = this.rewardsGrid.GetSubElement <UXElement>(itemUID, "IconUpgrade"); EquipmentVO nextLevel = Service.Get <EquipmentUpgradeCatalog>().GetNextLevel(eqp); string equipmentID = eqp.EquipmentID; if (nextLevel == null) { subElement3.Text = this.lang.Get("MAX_LEVEL", new object[0]); subElement.Value = 1f; return; } int num = currentPlayer.Shards.ContainsKey(equipmentID) ? currentPlayer.Shards[equipmentID] : 0; int upgradeShards; if (currentPlayer.UnlockedLevels.Equipment.Has(eqp)) { upgradeShards = nextLevel.UpgradeShards; subElement4.Visible = (num >= upgradeShards); } else { upgradeShards = eqp.UpgradeShards; } subElement3.Text = this.lang.Get("FRACTION", new object[] { num, upgradeShards }); if (upgradeShards == 0) { Service.Get <StaRTSLogger>().ErrorFormat("CMS Error: Shards required for {0} is zero", new object[] { nextLevel.Uid }); return; } float sliderValue = (float)num / (float)upgradeShards; UXUtils.SetShardProgressBarValue(subElement, subElement2, sliderValue); }
private void SetProgressBarElements(CurrentPlayer player, int quality) { UXSlider element = base.GetElement <UXSlider>("pBarFrag"); UXSprite element2 = base.GetElement <UXSprite>("SpritepBarFrag"); UXLabel element3 = base.GetElement <UXLabel>("LabelProgress"); UXLabel element4 = base.GetElement <UXLabel>("ItemStatus"); EquipmentVO nextLevel = Service.EquipmentUpgradeCatalog.GetNextLevel(this.selectedEquipment); UXElement element5 = base.GetElement <UXElement>("IconUpgrade"); string equipmentID = this.selectedEquipment.EquipmentID; element.Visible = true; element4.Visible = false; if (nextLevel == null) { element3.Text = this.lang.Get("MAX_LEVEL", new object[0]); element.Value = 0f; element5.Visible = false; return; } bool flag; if (this.forResearchLab) { flag = (this.activeContract != null && this.activeContract.ProductUid.Equals(nextLevel.Uid)); } else { Contract contract = Service.ISupportController.FindFirstContractWithProductUid(nextLevel.Uid); flag = (contract != null); } if (flag) { element.Visible = false; element5.Visible = false; return; } int num = (!player.Shards.ContainsKey(equipmentID)) ? 0 : player.Shards[equipmentID]; int upgradeShards; if (player.UnlockedLevels.Equipment.Has(this.selectedEquipment)) { upgradeShards = nextLevel.UpgradeShards; element5.Visible = (num >= upgradeShards); if (!this.forResearchLab) { element4.Visible = true; element4.Text = ((num < upgradeShards) ? this.lang.Get("EQUIPMENT_UPGRADE_LOCKED", new object[] { this.CalculateFragmentsNeededForUnlock(nextLevel.UpgradeShards, this.selectedEquipment.EquipmentID) }) : this.lang.Get("ARMORY_UPGRADE_CTA", new object[0])); } } else { upgradeShards = this.selectedEquipment.UpgradeShards; element5.Visible = false; } element3.Text = this.lang.Get("FRACTION", new object[] { num, upgradeShards }); if (upgradeShards == 0) { Service.Logger.ErrorFormat("CMS Error: Shards required for {0} is zero", new object[] { nextLevel.Uid }); return; } float sliderValue = (float)num / (float)upgradeShards; UXUtils.SetShardProgressBarValue(element, element2, sliderValue); }
private UXElement CreateInactiveCard(UXGrid grid, EquipmentVO equipment, CurrentPlayer currentPlayer) { UXElement uXElement = this.CreateCommonEquipmentCard(grid, equipment, "LabelEquipmentName", "LabelEquipmentLevel", "SpriteEquipmentItemImage", "EquipmentItemCardQ{0}", false, true); (uXElement.Tag as SortableEquipment).Player = currentPlayer; UXButton subElement = this.inactiveGrid.GetSubElement <UXButton>(equipment.Uid, "BtnEquipmentInfo"); subElement.OnClicked = new UXButtonClickedDelegate(this.OnInfoButtonClicked); subElement.Tag = equipment; UXButton subElement2 = this.inactiveGrid.GetSubElement <UXButton>(equipment.Uid, "BtnEquipmentItemCard"); subElement2.OnClicked = new UXButtonClickedDelegate(this.OnCardButtonClicked); subElement2.Tag = uXElement; EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog; UXSlider subElement3 = this.inactiveGrid.GetSubElement <UXSlider>(equipment.Uid, "pBarEquipmentItemFrag"); UXSprite subElement4 = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentItempBarFrag"); UXLabel subElement5 = grid.GetSubElement <UXLabel>(equipment.Uid, "LabelFragProgress"); UXElement subElement6 = this.inactiveGrid.GetSubElement <UXElement>(equipment.Uid, "IconUpgrade"); UXSprite subElement7 = grid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentImageBkgStroke"); UXSprite subElement8 = grid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentItemBarOutline"); UXSprite subElement9 = grid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentImageBkgGlow"); subElement7.Color = ArmoryScreen.qualityColor[equipment.Quality]; subElement8.Color = ArmoryScreen.qualityColor[equipment.Quality]; subElement9.Color = ArmoryScreen.qualityColor[equipment.Quality]; subElement9.Alpha = 0.4f; float sliderProgressValue = this.GetSliderProgressValue(equipment, currentPlayer.GetShards(equipment.EquipmentID)); UXSprite subElement10 = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteIconFragment"); UXUtils.SetupFragmentIconSprite(subElement10, (int)equipment.Quality); UXUtils.SetShardProgressBarValue(subElement3, subElement4, sliderProgressValue); subElement6.Visible = false; if (ArmoryUtils.IsAtMaxLevel(equipmentUpgradeCatalog, equipment)) { subElement5.Text = this.lang.Get("MAX_LEVEL", new object[0]); } else { int shards = currentPlayer.GetShards(equipment.EquipmentID); int shardsRequiredForNextUpgrade = ArmoryUtils.GetShardsRequiredForNextUpgrade(currentPlayer, equipmentUpgradeCatalog, equipment); if (shards >= shardsRequiredForNextUpgrade) { subElement5.Text = this.lang.Get("ARMORY_UPGRADE_NOW", new object[0]); } else { subElement5.Text = this.lang.Get("OBJECTIVE_PROGRESS", new object[] { shards, shardsRequiredForNextUpgrade }); } } if (ArmoryUtils.IsEquipmentOwned(currentPlayer, equipment)) { EquipmentVO nextLevel = equipmentUpgradeCatalog.GetNextLevel(equipment); if (nextLevel != null) { if (Service.ISupportController.FindFirstContractWithProductUid(nextLevel.Uid) != null) { subElement5.Visible = false; subElement3.Visible = false; } else if (currentPlayer.GetShards(equipment.EquipmentID) >= nextLevel.UpgradeShards) { subElement6.Visible = true; } } } this.SetDimmerBasedOnRequirements(currentPlayer, equipment); return(uXElement); }