public static void GrantInstantSpecialAttackUpgrade(string rewardString) { IDataController dataController = Service.Get <IDataController>(); UnlockedLevelData unlockedLevels = Service.Get <CurrentPlayer>().UnlockedLevels; string[] array = RewardUtils.ParsePairedStrings(rewardString, ':'); string uid = array[0]; int level = Convert.ToInt32(array[1], CultureInfo.InvariantCulture); SpecialAttackTypeVO optional = dataController.GetOptional <SpecialAttackTypeVO>(uid); if (optional != null) { StarshipUpgradeCatalog starshipUpgradeCatalog = Service.Get <StarshipUpgradeCatalog>(); SpecialAttackTypeVO byLevel = starshipUpgradeCatalog.GetByLevel(optional, level); if (byLevel != null) { unlockedLevels.Starships.SetLevel(byLevel); return; } } else { Service.Get <StaRTSLogger>().WarnFormat("Instant spec Attack upgrade {0} does not exist", new object[] { rewardString }); } }
public bool DoesUserHaveAnyUpgradeableShardUnits() { CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); TroopUpgradeCatalog troopUpgradeCatalog = Service.Get <TroopUpgradeCatalog>(); StarshipUpgradeCatalog starshipUpgradeCatalog = Service.Get <StarshipUpgradeCatalog>(); foreach (string current in troopUpgradeCatalog.AllUpgradeGroups()) { int nextLevel = currentPlayer.UnlockedLevels.Troops.GetNextLevel(current); TroopTypeVO byLevel = troopUpgradeCatalog.GetByLevel(current, nextLevel); if (byLevel != null && byLevel.PlayerFacing && byLevel.Type != TroopType.Champion && byLevel.Faction == currentPlayer.Faction && !string.IsNullOrEmpty(byLevel.UpgradeShardUid) && this.DoesUserHaveUpgradeShardRequirement(byLevel)) { bool result = true; return(result); } } foreach (string current2 in starshipUpgradeCatalog.AllUpgradeGroups()) { int nextLevel2 = currentPlayer.UnlockedLevels.Starships.GetNextLevel(current2); SpecialAttackTypeVO byLevel2 = starshipUpgradeCatalog.GetByLevel(current2, nextLevel2); if (byLevel2 != null && byLevel2.PlayerFacing && byLevel2.Faction == currentPlayer.Faction && !string.IsNullOrEmpty(byLevel2.UpgradeShardUid) && this.DoesUserHaveUpgradeShardRequirement(byLevel2)) { bool result = true; return(result); } } return(false); }
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); }
public static bool IsUpgradeStarshipContractValid(Contract contract) { SpecialAttackTypeVO upgradeable = Service.Get <IDataController>().Get <SpecialAttackTypeVO>(contract.ProductUid); StarshipUpgradeCatalog starshipUpgradeCatalog = Service.Get <StarshipUpgradeCatalog>(); CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); return(starshipUpgradeCatalog.CanUpgradeTo(currentPlayer.UnlockedLevels.Starships, upgradeable)); }
public static IUpgradeableVO GetFinalUnitFromPrize(PrizeType prizeType, string prizeID) { BuildingLookupController buildingLookupController = Service.Get <BuildingLookupController>(); IUpgradeableVO result = null; TroopUpgradeCatalog troopUpgradeCatalog = Service.Get <TroopUpgradeCatalog>(); switch (prizeType) { case PrizeType.Infantry: { int val = buildingLookupController.GetHighestLevelForBarracks(); int lvl = troopUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl; int level = Math.Min(val, lvl); result = troopUpgradeCatalog.GetByLevel(prizeID, level); break; } case PrizeType.Hero: { int val = buildingLookupController.GetHighestLevelForHeroCommands(); int lvl = troopUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl; int level = Math.Min(val, lvl); result = troopUpgradeCatalog.GetByLevel(prizeID, level); break; } case PrizeType.SpecialAttack: { StarshipUpgradeCatalog starshipUpgradeCatalog = Service.Get <StarshipUpgradeCatalog>(); int val = buildingLookupController.GetHighestLevelForStarshipCommands(); int lvl = starshipUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl; int level = Math.Min(val, lvl); result = starshipUpgradeCatalog.GetByLevel(prizeID, level); break; } case PrizeType.Vehicle: { int val = buildingLookupController.GetHighestLevelForFactories(); int lvl = troopUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl; int level = Math.Min(val, lvl); result = troopUpgradeCatalog.GetByLevel(prizeID, level); break; } case PrizeType.Mercenary: { int val = buildingLookupController.GetHighestLevelForCantinas(); int lvl = troopUpgradeCatalog.GetMaxRewardableLevel(prizeID).Lvl; int level = Math.Min(val, lvl); result = troopUpgradeCatalog.GetByLevel(prizeID, level); break; } } return(result); }
public TroopUpgradeScreen(SmartEntity trainingBuilding) : base("gui_upgrade_troops", trainingBuilding) { this.dataController = Service.StaticDataController; this.troopUpgradeCatalog = Service.TroopUpgradeCatalog; this.starshipUpgradeCatalog = Service.StarshipUpgradeCatalog; this.accumulatedUpdateDt = 0f; this.timerActive = false; this.eligibleDeployables = new List <TroopUpgradeScreen.DeployableUpgradeData>(); this.eligibleTroopTypes = new HashSet <TroopType>(); this.hasStarships = false; this.equipmentToDisplay = new List <EquipmentVO>(); this.RefreshDeployableData(); }
public List <SpecialAttackTypeVO> GetStarshipsUnlockedByBuilding(string reqBuildingUid) { StarshipUpgradeCatalog starshipUpgradeCatalog = Service.StarshipUpgradeCatalog; return(this.GetItemsUnlockedByBuilding <SpecialAttackTypeVO>(reqBuildingUid, starshipUpgradeCatalog)); }