public static bool IsUpgradeEquipmentContractValid(Contract contract) { EquipmentVO upgradeable = Service.Get <IDataController>().Get <EquipmentVO>(contract.ProductUid); EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.Get <EquipmentUpgradeCatalog>(); CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); return(equipmentUpgradeCatalog.CanUpgradeTo(currentPlayer.UnlockedLevels.Equipment, upgradeable)); }
private static bool PlayerHasEquipmentAvailable() { CurrentPlayer currentPlayer = Service.CurrentPlayer; EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog; foreach (string current in equipmentUpgradeCatalog.AllUpgradeGroups()) { if (!ArmoryUtils.HasReachedMaxEquipmentShards(currentPlayer, equipmentUpgradeCatalog, current)) { return(true); } } return(false); }
public static bool HasReachedMaxEquipmentShards(CurrentPlayer player, EquipmentUpgradeCatalog catalog, string equipmentID) { int level = player.UnlockedLevels.Equipment.GetLevel(equipmentID); EquipmentVO maxLevel = catalog.GetMaxLevel(equipmentID); int num = (maxLevel == null) ? 0 : maxLevel.Lvl; if (level >= num) { return(true); } int numEquipmentShardsToReachLevel = ArmoryUtils.GetNumEquipmentShardsToReachLevel(catalog, equipmentID, level, num); return(player.Shards.ContainsKey(equipmentID) && player.Shards[equipmentID] >= numEquipmentShardsToReachLevel); }
public static int GetNumEquipmentShardsToReachLevel(EquipmentUpgradeCatalog catalog, string equipmentID, int initialUnlockLevel, int maxLevel) { if (initialUnlockLevel >= maxLevel) { return(0); } int num = 0; for (int i = initialUnlockLevel + 1; i <= maxLevel; i++) { EquipmentVO byLevel = catalog.GetByLevel(equipmentID, i); num += byLevel.UpgradeShards; } return(num); }
private bool GetEquipmentShardUIInfoForCurrentItem(out int currentShardAmount, out int increasedShardAmount, out int shardsNeededForLevel, out bool showLevel, out EquipmentVO equipmentVoToDisplay) { currentShardAmount = 0; increasedShardAmount = 0; shardsNeededForLevel = 0; equipmentVoToDisplay = null; showLevel = false; CrateSupplyVO crateSupply = this.currentCrateItem.CrateSupply; if (crateSupply.Type != SupplyType.Shard) { return(false); } EquipmentVO equipment = this.currentCrateItem.Equipment; if (equipment == null) { return(false); } EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog; string equipmentID = equipment.EquipmentID; int num = (!this.shardsOriginal.ContainsKey(equipmentID)) ? 0 : this.shardsOriginal[equipmentID]; currentShardAmount = num; RewardVO reward = Service.InventoryCrateRewardController.GenerateRewardFromSupply(crateSupply, this.hq); int shardsRewarded = RewardUtils.GetShardsRewarded(reward); int num2 = num + shardsRewarded; increasedShardAmount = num2; EquipmentVO equipmentVO = equipment; showLevel = true; if (this.equipmentOriginal.ContainsKey(equipmentID)) { int num3 = this.equipmentOriginal[equipmentID]; int level = Mathf.Min(num3 + 1, equipmentUpgradeCatalog.GetMaxLevel(equipmentID).Lvl); equipmentVoToDisplay = equipmentUpgradeCatalog.GetByLevel(equipment, num3); equipmentVO = equipmentUpgradeCatalog.GetByLevel(equipmentVoToDisplay, level); } else { equipmentVoToDisplay = equipmentUpgradeCatalog.GetMinLevel(equipmentVO.EquipmentID); equipmentVO = equipmentVoToDisplay; showLevel = false; } shardsNeededForLevel = equipmentVO.UpgradeShards; return(true); }
private void PopulateEquipmentGrid() { EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog; CurrentPlayer currentPlayer = Service.CurrentPlayer; this.FindAllUpgradableEquipment(currentPlayer, equipmentUpgradeCatalog); int maxItemsPerLine = (this.equipmentToDisplay.Count + 1) / 2; this.equipmentGrid.MaxItemsPerLine = maxItemsPerLine; EquipmentTabHelper equipmentTabHelper = this.filterHelper as EquipmentTabHelper; EquipmentTab currentTab = (EquipmentTab)equipmentTabHelper.CurrentTab; List <UXElement> list = new List <UXElement>(); int i = 0; int count = this.equipmentToDisplay.Count; while (i < count) { EquipmentVO equipmentVO = this.equipmentToDisplay[i]; if (equipmentTabHelper.IsEquipmentValidForTab(equipmentVO, currentTab)) { if (this.contractHidden) { EquipmentVO nextLevel = equipmentUpgradeCatalog.GetNextLevel(equipmentVO); if (nextLevel.Uid == this.activeContract.ProductUid) { this.contractHidden = false; } } UXElement item = this.FetchEquipmentCardGridItem(currentPlayer, equipmentVO, equipmentUpgradeCatalog); list.Add(item); } i++; } UXUtils.SortListForTwoRowGrids(list, this.equipmentGrid); int j = 0; int count2 = list.Count; while (j < count2) { this.equipmentGrid.AddItem(list[j], j); j++; } list.Clear(); this.equipmentGrid.RepositionItemsFrameDelayed(new UXDragDelegate(this.FinishEquipmentGridSetup), 1); this.CheckActiveContract(); }
public EquipmentInfoScreen(EquipmentVO selectedEquipment, List <EquipmentVO> equipmentList, SmartEntity selectedBuilding, bool forResearchLab, bool forArmoryScreen) : base("gui_troop_info", selectedBuilding) { this.wantsTransition = false; this.shouldCloseParent = true; this.selectedEquipment = selectedEquipment; EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog; this.nextEquipmentVoUpgrade = equipmentUpgradeCatalog.GetNextLevel(selectedEquipment); this.equipmentList = equipmentList; this.forResearchLab = forResearchLab; this.forArmoryScreen = forArmoryScreen; if (forResearchLab) { this.CheckActiveContract(); } this.accumulatedUpdateDt = 0f; }
public static bool HasReachedMaxEquipmentShards(CurrentPlayer player, EquipmentUpgradeCatalog catalog, string equipmentID) { int level = player.UnlockedLevels.Equipment.GetLevel(equipmentID); EquipmentVO maxLevel = catalog.GetMaxLevel(equipmentID); int num = (maxLevel != null) ? maxLevel.Lvl : 0; if (level >= num) { return(true); } int num2 = 0; for (int i = level + 1; i <= num; i++) { EquipmentVO byLevel = catalog.GetByLevel(equipmentID, i); num2 += byLevel.UpgradeShards; } return(player.Shards.ContainsKey(equipmentID) && player.Shards[equipmentID] >= num2); }
private void FindAllUpgradableEquipment(CurrentPlayer player, EquipmentUpgradeCatalog catalog) { this.equipmentToDisplay.Clear(); foreach (string current in catalog.AllUpgradeGroups()) { int level = player.UnlockedLevels.Equipment.GetLevel(current); EquipmentVO equipmentVO = catalog.GetByLevel(current, level); if (equipmentVO == null) { equipmentVO = catalog.GetMaxLevel(current); } if (equipmentVO.PlayerFacing) { if (equipmentVO.Faction == player.Faction) { this.equipmentToDisplay.Add(equipmentVO); } } } this.equipmentToDisplay.Sort(new Comparison <EquipmentVO>(this.CompareBySortOrder)); }
private List <EquipmentVO> GenerateInactiveEquipmentList() { CurrentPlayer currentPlayer = Service.CurrentPlayer; IDictionary <string, int> levels = currentPlayer.UnlockedLevels.Equipment.Levels; EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog; List <string> iDCollection = equipmentUpgradeCatalog.GetIDCollection(); List <SortableEquipment> list = new List <SortableEquipment>(); EquipmentTab currentTab = (EquipmentTab)this.equipmentTabs.CurrentTab; int i = 0; int count = iDCollection.Count; while (i < count) { string text = iDCollection[i]; int level = 1; if (levels.ContainsKey(text)) { level = levels[text]; } EquipmentVO byLevel = equipmentUpgradeCatalog.GetByLevel(text, level); if (currentPlayer.Faction == byLevel.Faction && !currentPlayer.ActiveArmory.Equipment.Contains(byLevel.Uid)) { if (this.equipmentTabs.IsEquipmentValidForTab(byLevel, currentTab)) { list.Add(new SortableEquipment(currentPlayer, byLevel)); } } i++; } ArmorySortUtils.SortWithPriorityList(list, new List <EquipmentSortMethod> { EquipmentSortMethod.UnlockedEquipment, EquipmentSortMethod.RequirementsMet, EquipmentSortMethod.Quality, EquipmentSortMethod.CurrentPlanet, EquipmentSortMethod.CapacitySize, EquipmentSortMethod.Alphabetical }); return(ArmorySortUtils.RemoveWrapper(list)); }
private void OnPrevOrNextButtonClicked(UXButton button) { int num = (int)button.Tag; int count = this.equipmentList.Count; int index = (num >= 0) ? 0 : (count - 1); EquipmentVO equipmentVO = this.equipmentList[index]; for (int i = count - 1; i >= 0; i--) { int index2 = (num >= 0) ? i : (count - 1 - i); EquipmentVO equipmentVO2 = this.equipmentList[index2]; if (equipmentVO2 == this.selectedEquipment) { break; } equipmentVO = equipmentVO2; } this.selectedEquipment = equipmentVO; EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog; this.nextEquipmentVoUpgrade = equipmentUpgradeCatalog.GetNextLevel(this.selectedEquipment); this.Redraw(); }
public ShardShopViewTO GenerateViewTO(int index, CurrentPlayer player, ShardShopData data) { StaticDataController staticDataController = Service.StaticDataController; int playerHQLevel = player.Map.FindHighestHqLevel(); ShardShopViewTO shardShopViewTO = new ShardShopViewTO(); string shardSlotId = GameUtils.GetShardSlotId(index); int num = 0; foreach (int current in data.Purchases[index].Values) { num += current; } int num2 = this.adjustedOfferQuantity[index] - num; shardShopViewTO.SlotIndex = index; shardShopViewTO.SupplyVO = data.ShardOffers[shardSlotId]; shardShopViewTO.RemainingShardsForSale = num2; if (num2 > 0) { shardShopViewTO.CostOfNextShard = ShardShopController.CalculateCost(index, 1, data); shardShopViewTO.CostOfAllShards = ShardShopController.CalculateCost(index, num2, data); } shardShopViewTO.CanAffordSingle = CostUtils.HasRequiredCurrency(player, shardShopViewTO.CostOfNextShard); shardShopViewTO.CanAffordAll = CostUtils.HasRequiredCurrency(player, shardShopViewTO.CostOfAllShards); shardShopViewTO.PlayerHQLevel = playerHQLevel; shardShopViewTO.ItemName = GameUtils.GetShardShopNameWithoutQuantity(shardShopViewTO.SupplyVO, staticDataController); shardShopViewTO.Quality = GameUtils.GetShardQualityNumeric(shardShopViewTO.SupplyVO); shardShopViewTO.UpgradeShardsEarned = GameUtils.GetUpgradeShardsOwned(shardShopViewTO.SupplyVO, player); shardShopViewTO.UpgradeShardsRequired = GameUtils.GetUpgradeShardsRequired(shardShopViewTO.SupplyVO, player, staticDataController); shardShopViewTO.State = "unlocked"; SupplyType type = shardShopViewTO.SupplyVO.Type; if (this.adjustedOfferQuantity[index] < 1) { shardShopViewTO.State = "maxedOut"; } else if (num2 < 1) { shardShopViewTO.State = "soldOut"; } else if (type == SupplyType.Shard && !ArmoryUtils.PlayerHasArmory()) { shardShopViewTO.State = "requiresArmory"; } else if (type == SupplyType.ShardTroop) { ShardVO shardVO = staticDataController.Get <ShardVO>(shardShopViewTO.SupplyVO.RewardUid); TroopUpgradeCatalog troopUpgradeCatalog = Service.TroopUpgradeCatalog; TroopTypeVO byLevel = troopUpgradeCatalog.GetByLevel(shardVO.TargetGroupId, 1); if (byLevel != null && byLevel.Type == TroopType.Mercenary && !Service.BuildingLookupController.HasCantina()) { shardShopViewTO.State = "requiresCantina"; } } if (type == SupplyType.Shard) { EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog; EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(shardShopViewTO.SupplyVO.RewardUid); int shards = player.GetShards(shardShopViewTO.SupplyVO.RewardUid); int shardsRequiredForNextUpgrade = ArmoryUtils.GetShardsRequiredForNextUpgrade(player, equipmentUpgradeCatalog, currentEquipmentDataByID); shardShopViewTO.Upgradeable = (shards >= shardsRequiredForNextUpgrade && shardsRequiredForNextUpgrade > 0); } else if (type == SupplyType.ShardTroop || type == SupplyType.ShardSpecialAttack) { shardShopViewTO.Upgradeable = Service.DeployableShardUnlockController.IsShardDeployableReadyToUpgrade(shardShopViewTO.SupplyVO.RewardUid); } return(shardShopViewTO); }
private UXElement FetchEquipmentCardGridItem(CurrentPlayer player, EquipmentVO equipmentVO, EquipmentUpgradeCatalog catalog) { UXElement result = this.equipmentGrid.CloneTemplateItem(equipmentVO.Uid); string uid = equipmentVO.Uid; EquipmentVO nextLevel = catalog.GetNextLevel(equipmentVO); ShardQuality quality = equipmentVO.Quality; UXUtils.SetCardQuality(this, this.equipmentGrid, uid, (int)quality, "EquipmentItemCardQ{0}"); UXLabel subElement = this.equipmentGrid.GetSubElement <UXLabel>(uid, "LabelEquipmentName"); subElement.Text = this.lang.Get(equipmentVO.EquipmentName, new object[0]); UXLabel subElement2 = this.equipmentGrid.GetSubElement <UXLabel>(uid, "LabelEquipmentLevel"); subElement2.Text = LangUtils.GetLevelText(equipmentVO.Lvl); UXButton subElement3 = this.equipmentGrid.GetSubElement <UXButton>(uid, "BtnEquipmentItemCard"); subElement3.Tag = equipmentVO; subElement3.OnClicked = new UXButtonClickedDelegate(this.OnEquipmentButtonClicked); this.troopGrid.GetSubElement <UXSlider>(uid, "pBarUpgradeTimeEquipment").Visible = false; this.troopGrid.GetSubElement <UXLabel>(uid, "LabelpBarUpgradeTimeEquipment").Visible = false; UXSprite subElement4 = this.equipmentGrid.GetSubElement <UXSprite>(uid, "SpriteFragmentEquip"); UXUtils.SetupFragmentIconSprite(subElement4, (int)quality); UXSprite subElement5 = this.equipmentGrid.GetSubElement <UXSprite>(uid, "SpriteEquipmentItemImage"); ProjectorConfig config = ProjectorUtils.GenerateEquipmentConfig(equipmentVO, subElement5, true); ProjectorUtils.GenerateProjector(config); UXLabel subElement6 = this.equipmentGrid.GetSubElement <UXLabel>(uid, "LabelEquipmentNumber"); UXSlider subElement7 = this.equipmentGrid.GetSubElement <UXSlider>(uid, "pBarFrag"); UXSprite subElement8 = this.equipmentGrid.GetSubElement <UXSprite>(uid, "SpritepBarFrag"); subElement8.Color = UXUtils.COLOR_SHARD_INPROGRESS; UXLabel subElement9 = this.equipmentGrid.GetSubElement <UXLabel>(uid, "LabelEquipmentRequirement"); UXSprite subElement10 = this.equipmentGrid.GetSubElement <UXSprite>(uid, "SpriteDim"); UXSprite subElement11 = this.equipmentGrid.GetSubElement <UXSprite>(uid, "SpriteIconLockedEquip"); UXElement subElement12 = this.equipmentGrid.GetSubElement <UXElement>(uid, "IconUpgrade"); if (!player.UnlockedLevels.Equipment.Has(equipmentVO)) { subElement9.Text = LangUtils.GetShardLockedEquipmentString(equipmentVO); subElement10.Visible = true; subElement11.Visible = true; subElement2.Visible = false; int shards = player.GetShards(equipmentVO.EquipmentID); subElement6.Text = this.lang.Get("OBJECTIVE_PROGRESS", new object[] { shards, equipmentVO.UpgradeShards }); subElement7.Value = this.CalculateProgress(shards, equipmentVO); subElement12.Visible = false; } else if (nextLevel == null) { subElement6.Visible = false; subElement10.Visible = true; subElement11.Visible = false; subElement6.Visible = false; subElement9.Text = this.lang.Get("MAX_LEVEL", new object[0]); subElement7.Visible = false; subElement12.Visible = false; } else { int shards2 = player.GetShards(equipmentVO.EquipmentID); subElement6.Text = this.lang.Get("OBJECTIVE_PROGRESS", new object[] { shards2, nextLevel.UpgradeShards }); subElement7.Value = this.CalculateProgress(shards2, nextLevel); subElement12.Visible = (shards2 >= nextLevel.UpgradeShards); if (subElement12.Visible) { subElement8.Color = UXUtils.COLOR_SHARD_COMPLETE; } if (ArmoryUtils.IsBuildingRequirementMet(nextLevel)) { subElement9.Visible = false; subElement10.Visible = false; subElement11.Visible = false; } else { BuildingTypeVO buildingInfo = this.dataController.Get <BuildingTypeVO>(nextLevel.BuildingRequirement); subElement9.Text = this.lang.Get("BUILDING_REQUIREMENT", new object[] { nextLevel.Lvl, LangUtils.GetBuildingDisplayName(buildingInfo) }); subElement10.Visible = true; subElement11.Visible = true; } } return(result); }
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); }
public static EquipmentVO GetEquipmentDataByID(string equipmentID, int level) { EquipmentUpgradeCatalog equipmentUpgradeCatalog = Service.Get <EquipmentUpgradeCatalog>(); return(equipmentUpgradeCatalog.GetByLevel(equipmentID, level)); }
public static bool IsAtMaxLevel(EquipmentUpgradeCatalog equipmentUpgradeCatalog, EquipmentVO equipmentVO) { EquipmentVO maxLevel = equipmentUpgradeCatalog.GetMaxLevel(equipmentVO.EquipmentID); return(maxLevel.Lvl == equipmentVO.Lvl); }
public static int GetShardsRequiredForNextUpgrade(CurrentPlayer currentPlayer, EquipmentUpgradeCatalog equipmentCatalog, EquipmentVO equipmentVO) { if (!ArmoryUtils.IsEquipmentOwned(currentPlayer, equipmentVO)) { EquipmentVO minLevel = equipmentCatalog.GetMinLevel(equipmentVO.EquipmentID); return(minLevel.UpgradeShards); } EquipmentVO nextLevel = equipmentCatalog.GetNextLevel(equipmentVO); if (nextLevel == null) { return(-1); } return(nextLevel.UpgradeShards); }