Пример #1
0
        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);
        }
Пример #2
0
        public static BattleInitializationData CreateFromMemberWarData(SquadMemberWarData memberWarData, Dictionary <string, int> donatedSquadTroops, Dictionary <string, int> champions, FactionType faction, string participantSquadId, List <string> equipment)
        {
            BattleInitializationData battleInitializationData = new BattleInitializationData();

            battleInitializationData.BattleType = BattleType.PvpAttackSquadWar;
            CurrentPlayer currentPlayer = Service.CurrentPlayer;

            battleInitializationData.Attacker                     = new BattleParticipant(currentPlayer.PlayerId, currentPlayer.PlayerName, currentPlayer.Faction);
            battleInitializationData.Attacker.GuildId             = Service.SquadController.StateManager.GetCurrentSquad().SquadID;
            battleInitializationData.Defender                     = new BattleParticipant(memberWarData.SquadMemberId, memberWarData.SquadMemberName, faction);
            battleInitializationData.Defender.GuildId             = participantSquadId;
            battleInitializationData.AttackerDeployableData       = BattleDeploymentData.CreateEmpty();
            battleInitializationData.DefenderDeployableData       = BattleDeploymentData.CreateEmpty();
            battleInitializationData.AllowMultipleHeroDeploys     = false;
            battleInitializationData.OverrideDeployables          = false;
            battleInitializationData.BattleLength                 = GameConstants.PVP_MATCH_DURATION;
            battleInitializationData.PlanetId                     = memberWarData.BaseMap.Planet.Uid;
            battleInitializationData.MemberWarData                = memberWarData;
            battleInitializationData.VictoryConditions            = Service.VictoryConditionController.GetDefaultConditions();
            battleInitializationData.DefenderGuildTroopsAvailable = donatedSquadTroops;
            battleInitializationData.DefenderChampionsAvailable   = champions;
            battleInitializationData.AttackerGuildTroopsAvailable = BattleInitializationData.GetCurrentPlayerGuildTroops();
            battleInitializationData.DisabledBuildings            = null;
            battleInitializationData.IsReplay                     = false;
            battleInitializationData.IsRevenge                    = false;
            battleInitializationData.AllowReplay                  = true;
            SquadWarManager warManager = Service.SquadController.WarManager;

            battleInitializationData.AttackerWarBuffs  = warManager.GetBuffBasesOwnedBySquad(battleInitializationData.Attacker.GuildId);
            battleInitializationData.DefenderWarBuffs  = warManager.GetBuffBasesOwnedBySquad(battleInitializationData.Defender.GuildId);
            battleInitializationData.AttackerEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId);
            battleInitializationData.DefenderEquipment = equipment;
            return(battleInitializationData);
        }
Пример #3
0
 public static BattleInitializationData CreateEmpty(BattleType type)
 {
     return(new BattleInitializationData
     {
         BattleType = type,
         AttackerDeployableData = BattleDeploymentData.CreateEmpty(),
         DefenderDeployableData = BattleDeploymentData.CreateEmpty(),
         AllowMultipleHeroDeploys = false,
         OverrideDeployables = false,
         BattleLength = GameConstants.PVP_MATCH_DURATION,
         VictoryConditions = Service.VictoryConditionController.GetDefaultConditions(),
         IsReplay = false,
         IsRevenge = false,
         AllowReplay = false
     });
 }
Пример #4
0
        public static BattleInitializationData CreateFromPvpTargetData(PvpTarget target, bool isRevenge)
        {
            BattleInitializationData battleInitializationData = new BattleInitializationData();

            battleInitializationData.RecordId   = target.BattleId;
            battleInitializationData.BattleType = BattleType.Pvp;
            CurrentPlayer currentPlayer = Service.CurrentPlayer;

            battleInitializationData.Attacker = new BattleParticipant(currentPlayer.PlayerId, currentPlayer.PlayerName, currentPlayer.Faction);
            battleInitializationData.Attacker.AttackRating  = currentPlayer.AttackRating;
            battleInitializationData.Attacker.DefenseRating = currentPlayer.DefenseRating;
            battleInitializationData.Defender = new BattleParticipant(target.PlayerId, target.PlayerName, target.PlayerFaction);
            battleInitializationData.Defender.AttackRating    = target.PlayerAttackRating;
            battleInitializationData.Defender.DefenseRating   = target.PlayerDefenseRating;
            battleInitializationData.AttackerDeployableData   = BattleDeploymentData.CreateEmpty();
            battleInitializationData.DefenderDeployableData   = BattleDeploymentData.CreateEmpty();
            battleInitializationData.AllowMultipleHeroDeploys = false;
            battleInitializationData.OverrideDeployables      = false;
            battleInitializationData.BattleLength             = GameConstants.PVP_MATCH_DURATION;
            battleInitializationData.PlanetId                     = target.BaseMap.Planet.Uid;
            battleInitializationData.LootCreditsAvailable         = target.AvailableCredits;
            battleInitializationData.LootMaterialsAvailable       = target.AvailableMaterials;
            battleInitializationData.LootContrabandAvailable      = target.AvailableContraband;
            battleInitializationData.BuildingLootCreditsMap       = target.BuildingLootCreditsMap;
            battleInitializationData.BuildingLootMaterialsMap     = target.BuildingLootMaterialsMap;
            battleInitializationData.BuildingLootContrabandMap    = target.BuildingLootContrabandMap;
            battleInitializationData.PvpTarget                    = target;
            battleInitializationData.VictoryConditions            = Service.VictoryConditionController.GetDefaultConditions();
            battleInitializationData.DefenderGuildTroopsAvailable = target.GuildDonatedTroops;
            battleInitializationData.DefenderChampionsAvailable   = target.Champions;
            battleInitializationData.AttackerGuildTroopsAvailable = BattleInitializationData.GetCurrentPlayerGuildTroops();
            battleInitializationData.DisabledBuildings            = new List <string>();
            for (int i = 0; i < target.Contracts.Count; i++)
            {
                if (target.Contracts[i].ContractType == ContractType.Build || target.Contracts[i].ContractType == ContractType.Upgrade)
                {
                    battleInitializationData.DisabledBuildings.Add(target.Contracts[i].BuildingKey);
                }
            }
            battleInitializationData.IsReplay          = false;
            battleInitializationData.IsRevenge         = isRevenge;
            battleInitializationData.AllowReplay       = true;
            battleInitializationData.AttackerEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId);
            battleInitializationData.DefenderEquipment = target.Equipment;
            return(battleInitializationData);
        }
Пример #5
0
        public static BattleDeploymentData Copy(BattleDeploymentData deploymentData)
        {
            BattleDeploymentData battleDeploymentData = new BattleDeploymentData();

            if (deploymentData.TroopData != null)
            {
                battleDeploymentData.TroopData = new Dictionary <string, int>(deploymentData.TroopData);
            }
            if (deploymentData.SpecialAttackData != null)
            {
                battleDeploymentData.SpecialAttackData = new Dictionary <string, int>(deploymentData.SpecialAttackData);
            }
            if (deploymentData.HeroData != null)
            {
                battleDeploymentData.HeroData = new Dictionary <string, int>(deploymentData.HeroData);
            }
            if (deploymentData.ChampionData != null)
            {
                battleDeploymentData.ChampionData = new Dictionary <string, int>(deploymentData.ChampionData);
            }
            if (deploymentData.SquadData != null)
            {
                battleDeploymentData.SquadData = new Dictionary <string, int>(deploymentData.SquadData);
            }
            if (deploymentData.TroopDataList != null)
            {
                battleDeploymentData.TroopDataList = new List <DeploymentRecord>(deploymentData.TroopDataList);
            }
            if (deploymentData.SpecialAttackDataList != null)
            {
                battleDeploymentData.SpecialAttackDataList = new List <DeploymentRecord>(deploymentData.SpecialAttackDataList);
            }
            if (deploymentData.HeroDataList != null)
            {
                battleDeploymentData.HeroDataList = new List <DeploymentRecord>(deploymentData.HeroDataList);
            }
            if (deploymentData.ChampionDataList != null)
            {
                battleDeploymentData.ChampionDataList = new List <DeploymentRecord>(deploymentData.ChampionDataList);
            }
            return(battleDeploymentData);
        }
Пример #6
0
 public unsafe static long $Invoke1(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(BattleDeploymentData.CreateEmpty()));
 }
Пример #7
0
 public unsafe static long $Invoke0(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(BattleDeploymentData.Copy((BattleDeploymentData)GCHandledObjects.GCHandleToObject(*args))));
 }
Пример #8
0
        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);
        }