public static BattleInitializationData CreateFromBattleTypeVO(string id) { BattleTypeVO battleTypeVO = Service.StaticDataController.Get <BattleTypeVO>(id); BattleInitializationData battleInitializationData = new BattleInitializationData(); battleInitializationData.BattleType = BattleType.PveFue; CurrentPlayer currentPlayer = Service.CurrentPlayer; battleInitializationData.Attacker = new BattleParticipant(currentPlayer.PlayerId, currentPlayer.PlayerName, currentPlayer.Faction); battleInitializationData.Defender = new BattleParticipant(battleTypeVO.DefenderId, battleTypeVO.DefenderId, FactionType.Invalid); battleInitializationData.BattleVO = battleTypeVO; battleInitializationData.AttackerDeployableData = BattleDeploymentData.Copy(battleTypeVO); battleInitializationData.DefenderDeployableData = BattleDeploymentData.CreateEmpty(); battleInitializationData.AllowMultipleHeroDeploys = false; battleInitializationData.OverrideDeployables = false; battleInitializationData.PlanetId = battleTypeVO.Planet; battleInitializationData.BattleLength = battleTypeVO.BattleTime; if (battleInitializationData.BattleLength == 0) { battleInitializationData.BattleLength = GameConstants.PVP_MATCH_DURATION; } battleInitializationData.VictoryConditions = Service.VictoryConditionController.GetDefaultConditions(); battleInitializationData.IsReplay = false; battleInitializationData.IsRevenge = false; battleInitializationData.DefenseEncounterProfile = battleTypeVO.EncounterProfile; battleInitializationData.BattleScript = battleTypeVO.BattleScript; battleInitializationData.AllowReplay = true; battleInitializationData.DisabledBuildings = new List <string>(); return(battleInitializationData); }
public unsafe static long $Invoke0(long instance, long *args) { return(GCHandledObjects.ObjectToGCHandle(BattleDeploymentData.Copy((BattleDeploymentData)GCHandledObjects.GCHandleToObject(*args)))); }
public static BattleInitializationData CreateFromDefensiveCampaignMissionVO(CampaignMissionVO vo) { StaticDataController staticDataController = Service.StaticDataController; string uid = vo.Uid; BattleInitializationData battleInitializationData = new BattleInitializationData(); CurrentPlayer currentPlayer = Service.CurrentPlayer; battleInitializationData.Attacker = new BattleParticipant(vo.OpponentName, vo.OpponentName, FactionType.Invalid); battleInitializationData.Defender = new BattleParticipant(currentPlayer.PlayerId, currentPlayer.PlayerName, currentPlayer.Faction); battleInitializationData.PlanetId = currentPlayer.Map.Planet.Uid; battleInitializationData.BattleType = BattleType.PveDefend; battleInitializationData.MissionUid = vo.Uid; BattleDeploymentData battleDeploymentData = new BattleDeploymentData(); battleDeploymentData.TroopData = new Dictionary <string, int>(); List <DefenseWave> list = DefensiveBattleController.ParseWaves(vo.Waves); foreach (DefenseWave current in list) { List <DefenseTroopGroup> list2 = DefensiveBattleController.ParseTroopGroups(uid, current.Encounter.WaveGroup, 0); foreach (DefenseTroopGroup current2 in list2) { if (battleDeploymentData.TroopData.ContainsKey(current2.TroopUid)) { Dictionary <string, int> dictionary; string troopUid; (dictionary = battleDeploymentData.TroopData)[troopUid = current2.TroopUid] = dictionary[troopUid] + current2.Quantity; } else { battleDeploymentData.TroopData.Add(current2.TroopUid, current2.Quantity); } } } battleInitializationData.AttackerDeployableData = battleDeploymentData; if (vo.Map != null) { battleInitializationData.BattleVO = staticDataController.Get <BattleTypeVO>(vo.Map); battleInitializationData.AllowMultipleHeroDeploys = (battleInitializationData.BattleVO.MultipleHeroDeploys || vo.IsRaidDefense()); battleInitializationData.OverrideDeployables = battleInitializationData.BattleVO.OverridePlayerUnits; battleInitializationData.BattleLength = battleInitializationData.BattleVO.BattleTime; battleInitializationData.DefenderDeployableData = BattleDeploymentData.Copy(battleInitializationData.BattleVO); } else { battleInitializationData.DefenderDeployableData = BattleDeploymentData.CreateEmpty(); battleInitializationData.AllowMultipleHeroDeploys = vo.IsRaidDefense(); battleInitializationData.OverrideDeployables = false; } Inventory inventory = currentPlayer.Inventory; battleInitializationData.LootCreditsAvailable = inventory.GetItemAmount("credits"); battleInitializationData.LootMaterialsAvailable = inventory.GetItemAmount("materials"); battleInitializationData.LootContrabandAvailable = inventory.GetItemAmount("contraband"); if (battleInitializationData.BattleLength == 0) { battleInitializationData.BattleLength = GameConstants.PVP_MATCH_DURATION; } battleInitializationData.BattleMusic = vo.BattleMusic; battleInitializationData.AmbientMusic = vo.AmbientMusic; battleInitializationData.VictoryConditions = vo.Conditions; if (!string.IsNullOrEmpty(vo.FailureCondition)) { battleInitializationData.FailureCondition = staticDataController.Get <ConditionVO>(vo.FailureCondition); } battleInitializationData.DisabledBuildings = new List <string>(); List <Contract> list3 = Service.ISupportController.FindAllContractsThatConsumeDroids(); for (int i = 0; i < list3.Count; i++) { if (list3[i].DeliveryType != DeliveryType.ClearClearable) { battleInitializationData.DisabledBuildings.Add(list3[i].ContractTO.BuildingKey); } } battleInitializationData.IsReplay = false; battleInitializationData.IsRevenge = false; battleInitializationData.AllowReplay = false; if (vo.IsRaidDefense() && Service.RaidDefenseController.SquadTroopDeployAllowed()) { battleInitializationData.DefenderGuildTroopsAvailable = new Dictionary <string, int>(); List <SquadDonatedTroop> troops = Service.SquadController.StateManager.Troops; for (int j = 0; j < troops.Count; j++) { string troopUid2 = troops[j].TroopUid; int totalAmount = troops[j].GetTotalAmount(); if (battleInitializationData.DefenderGuildTroopsAvailable.ContainsKey(troopUid2)) { Dictionary <string, int> dictionary; string key; (dictionary = battleInitializationData.DefenderGuildTroopsAvailable)[key = troopUid2] = dictionary[key] + totalAmount; } else { battleInitializationData.DefenderGuildTroopsAvailable.Add(troopUid2, totalAmount); } } } battleInitializationData.AttackerEquipment = null; battleInitializationData.DefenderEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId); return(battleInitializationData); }