public InventoryCrateAnimation GrantInventoryCrateReward(List <string> crateSupplyDataList, CrateData crateData) { CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); if (crateSupplyDataList == null || crateSupplyDataList.Count <= 0) { return(null); } if (crateData == null) { return(null); } this.IsCrateAnimationShowingOrPending = true; UnlockedLevelData unlockedLevels = Service.Get <CurrentPlayer>().UnlockedLevels; Dictionary <string, int> shardsOriginal = new Dictionary <string, int>(currentPlayer.Shards); Dictionary <string, int> troopUpgradeOriginal = new Dictionary <string, int>(unlockedLevels.Troops.Levels); Dictionary <string, int> specialAttackUpgradeOriginal = new Dictionary <string, int>(unlockedLevels.Starships.Levels); Dictionary <string, int> equipmentOriginal = new Dictionary <string, int>(currentPlayer.UnlockedLevels.Equipment.Levels); List <CrateSupplyVO> list = new List <CrateSupplyVO>(); int hQLevel = crateData.HQLevel; int i = 0; int count = crateSupplyDataList.Count; while (i < count) { list.Add(this.GrantSingleSupplyCrateReward(crateSupplyDataList[i], hQLevel)); i++; } return(this.ShowInventoryCrateAnimation(list, crateData, shardsOriginal, equipmentOriginal, troopUpgradeOriginal, specialAttackUpgradeOriginal)); }
public int GetUpgradeLevelOfDeployable(string type, string groupId) { int result = 0; UnlockedLevelData unlockedLevels = Service.CurrentPlayer.UnlockedLevels; if (type == "hero" || type == "troop") { if (unlockedLevels.Troops.Has(groupId)) { result = unlockedLevels.Troops.GetLevel(groupId); } } else if (type == "specialAttack") { if (unlockedLevels.Starships.Has(groupId)) { result = unlockedLevels.Starships.GetLevel(groupId); } } else { Service.Logger.Error("GetUpgradeLevelOfDeployable; Unexpected type: " + type + "with group: " + groupId); } return(result); }
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 static void GrantInstantTroopHeroUpgrade(string rewardString) { StaticDataController staticDataController = Service.StaticDataController; UnlockedLevelData unlockedLevels = Service.CurrentPlayer.UnlockedLevels; string[] array = RewardUtils.ParsePairedStrings(rewardString, ':'); string uid = array[0]; int level = Convert.ToInt32(array[1]); TroopTypeVO optional = staticDataController.GetOptional <TroopTypeVO>(uid); if (optional != null) { TroopUpgradeCatalog troopUpgradeCatalog = Service.TroopUpgradeCatalog; TroopTypeVO byLevel = troopUpgradeCatalog.GetByLevel(optional, level); if (byLevel != null) { unlockedLevels.Troops.SetLevel(byLevel); } } else { Service.Logger.WarnFormat("Instant unit upgrade {0} does not exist", new object[] { rewardString }); } }
private void UpgradeChampionToMatchPlatform(SmartEntity building) { BuildingTypeVO buildingType = building.BuildingComp.BuildingType; TroopTypeVO troopTypeVO = this.FindChampionTypeIfPlatform(buildingType); if (troopTypeVO == null) { return; } BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>(); BuildingTypeVO nextLevel = buildingUpgradeCatalog.GetNextLevel(buildingType); TroopTypeVO troopTypeVO2 = this.FindChampionTypeIfPlatform(nextLevel); if (troopTypeVO2 == null) { return; } this.AddChampionToInventoryIfAlive(building, false); CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); UnlockedLevelData.UpgradeTroopsOrStarshipsInventory(currentPlayer.Inventory.Champion, false, troopTypeVO2.UpgradeGroup, troopTypeVO2.Uid); this.DestroyChampionEntity(troopTypeVO); if (Service.Get <GameStateMachine>().CurrentState is HomeState) { this.CreateChampionEntity(troopTypeVO2, building); } }
private void AttemptToUpgradeUnitWithShards(string shardId, int level) { if (level <= 0) { return; } CurrentPlayer currentPlayer = Service.CurrentPlayer; Dictionary <string, int> shards = currentPlayer.Shards; StaticDataController staticDataController = Service.StaticDataController; ShardVO shardVO = staticDataController.Get <ShardVO>(shardId); string targetType = shardVO.TargetType; string targetGroupId = shardVO.TargetGroupId; bool flag = targetType == "specialAttack"; int num = 0; if (shards.ContainsKey(shardId)) { num += shards[shardId]; } int startLevel = level - 1; int numShardsForDeployableToReachLevelInGroup; if (flag) { numShardsForDeployableToReachLevelInGroup = this.GetNumShardsForDeployableToReachLevelInGroup <SpecialAttackTypeVO>(startLevel, level, targetGroupId); } else { numShardsForDeployableToReachLevelInGroup = this.GetNumShardsForDeployableToReachLevelInGroup <TroopTypeVO>(startLevel, level, targetGroupId); } if (num >= numShardsForDeployableToReachLevelInGroup) { UnlockedLevelData unlockedLevels = Service.CurrentPlayer.UnlockedLevels; IDeployableVO deployableVOForLevelInGroup; if (flag) { deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup <SpecialAttackTypeVO>(1, targetGroupId); } else { deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup <TroopTypeVO>(1, targetGroupId); } if (deployableVOForLevelInGroup == null) { return; } unlockedLevels.UpgradeTroopsOrStarships(deployableVOForLevelInGroup.Uid, flag); currentPlayer.ModifyShardAmount(shardId, num - numShardsForDeployableToReachLevelInGroup); Service.EventManager.SendEvent(EventId.ShardUnitUpgraded, deployableVOForLevelInGroup); } }
public override ISerializable FromObject(object obj) { Dictionary <string, object> dictionary = obj as Dictionary <string, object>; if (dictionary.ContainsKey("player")) { Dictionary <string, object> dictionary2 = dictionary["player"] as Dictionary <string, object>; this.Name = (dictionary2["name"] as string); if (dictionary2.ContainsKey("scalars")) { Dictionary <string, object> dictionary3 = dictionary2["scalars"] as Dictionary <string, object>; if (dictionary3.ContainsKey("attackRating")) { this.AttackRating = Convert.ToInt32(dictionary3["attackRating"], CultureInfo.InvariantCulture); } if (dictionary3.ContainsKey("defenseRating")) { this.DefenseRating = Convert.ToInt32(dictionary3["defenseRating"], CultureInfo.InvariantCulture); } if (dictionary3.ContainsKey("attacksWon")) { this.AttacksWon = Convert.ToInt32(dictionary3["attacksWon"], CultureInfo.InvariantCulture); } if (dictionary3.ContainsKey("defensesWon")) { this.DefensesWon = Convert.ToInt32(dictionary3["defensesWon"], CultureInfo.InvariantCulture); } } if (dictionary2.ContainsKey("playerModel")) { Dictionary <string, object> dictionary4 = dictionary2["playerModel"] as Dictionary <string, object>; if (dictionary4.ContainsKey("map")) { this.MapData = new Map(); this.MapData.FromObject(dictionary4["map"]); this.MapData.InitializePlanet(); } Dictionary <string, object> dictionary5 = dictionary4["inventory"] as Dictionary <string, object>; if (dictionary5.ContainsKey("capacity") && dictionary5["capacity"] != null) { this.InventoryData = new Inventory(); this.InventoryData.FromObject(dictionary4["inventory"]); } this.Faction = StringUtils.ParseEnum <FactionType>(dictionary4["faction"].ToString()); if (dictionary4.ContainsKey("guildInfo")) { Dictionary <string, object> dictionary6 = dictionary4["guildInfo"] as Dictionary <string, object>; if (dictionary6 != null && dictionary6.ContainsKey("guildId")) { string squadID = dictionary6["guildId"] as string; this.Squad = Service.Get <LeaderboardController>().GetOrCreateSquad(squadID); this.Squad.FromVisitNeighborObject(dictionary6); } } if (dictionary4.ContainsKey("donatedTroops")) { this.SquadTroops = SquadUtils.GetSquadDonatedTroopsFromObject(dictionary4["donatedTroops"]); } if (dictionary4.ContainsKey("upgrades")) { this.UpgradesData = new UnlockedLevelData(); this.UpgradesData.FromObject(dictionary4["upgrades"]); } } return(this); } Service.Get <StaRTSLogger>().Error("Unable to parse response for neighbor.visit"); return(null); }