Beispiel #1
0
        public static List <IAssetVO> GetBattleRecordPreloads(BattleRecord battleRecord)
        {
            List <IAssetVO> list = new List <IAssetVO>();

            if (battleRecord == null)
            {
                Service.Logger.Error("Battle Record is null in MapDataLoaderUtils.GetBattleRecordPreloads.");
                return(list);
            }
            StaticDataController staticDataController   = Service.StaticDataController;
            SkinController       skinController         = Service.SkinController;
            BattleDeploymentData attackerDeploymentData = battleRecord.AttackerDeploymentData;

            if (attackerDeploymentData != null)
            {
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(attackerDeploymentData.TroopData, list, battleRecord.AttackerEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <SpecialAttackTypeVO>(attackerDeploymentData.SpecialAttackData, list, battleRecord.AttackerEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(attackerDeploymentData.HeroData, list, battleRecord.AttackerEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(attackerDeploymentData.ChampionData, list, battleRecord.AttackerEquipment, staticDataController, skinController);
            }
            BattleDeploymentData defenderDeploymentData = battleRecord.DefenderDeploymentData;

            if (defenderDeploymentData != null)
            {
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(defenderDeploymentData.TroopData, list, battleRecord.DefenderEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <SpecialAttackTypeVO>(defenderDeploymentData.SpecialAttackData, list, battleRecord.DefenderEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(defenderDeploymentData.HeroData, list, battleRecord.DefenderEquipment, staticDataController, skinController);
                MapDataLoaderUtils.AddDeployablesToList <TroopTypeVO>(defenderDeploymentData.ChampionData, list, battleRecord.DefenderEquipment, staticDataController, skinController);
            }
            MapDataLoaderUtils.AddFXPreloads(list);
            return(list);
        }
Beispiel #2
0
        public static List <IAssetVO> GetBattleRecordProjectileAssets(Map map, BattleRecord battleRecord, List <string> attackerWarBuffs, List <string> defenderWarBuffs, List <string> attackerEquipment, List <string> defenderEquipment)
        {
            IDataController      dc   = Service.Get <IDataController>();
            List <IAssetVO>      list = new List <IAssetVO>();
            BattleDeploymentData attackerDeploymentData = battleRecord.AttackerDeploymentData;

            if (attackerDeploymentData != null)
            {
                ProjectileUtils.AddTroopProjectileAssets(attackerDeploymentData.TroopData, list, dc);
                ProjectileUtils.AddSpecialAttackProjectileAssets(attackerDeploymentData.SpecialAttackData, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(attackerDeploymentData.HeroData, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(attackerDeploymentData.ChampionData, list, dc);
            }
            BattleDeploymentData defenderDeploymentData = battleRecord.DefenderDeploymentData;

            if (defenderDeploymentData != null)
            {
                ProjectileUtils.AddTroopProjectileAssets(defenderDeploymentData.TroopData, list, dc);
                ProjectileUtils.AddSpecialAttackProjectileAssets(defenderDeploymentData.SpecialAttackData, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(defenderDeploymentData.HeroData, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(defenderDeploymentData.ChampionData, list, dc);
            }
            Dictionary <string, int> attackerGuildTroops = battleRecord.AttackerGuildTroops;

            ProjectileUtils.AddTroopProjectileAssets(attackerGuildTroops, list, dc);
            Dictionary <string, int> defenderGuildTroops = battleRecord.DefenderGuildTroops;

            ProjectileUtils.AddTroopProjectileAssets(defenderGuildTroops, list, dc);
            Dictionary <string, int> defenderChampions = battleRecord.DefenderChampions;

            ProjectileUtils.AddTroopProjectileAssets(defenderChampions, list, dc);
            ProjectileUtils.AddBattleProjectileAssets(map, null, null, attackerWarBuffs, defenderWarBuffs, attackerEquipment, defenderEquipment, list, dc);
            return(list);
        }
        public void StartRecord()
        {
            this.EraseRecord();
            foreach (EventId current in this.eventHandlers.Keys)
            {
                this.eventManager.RegisterObserver(this, current, EventPriority.Default);
            }
            this.battleRecord.LowestFPS = 9999f;
            Service.Get <PerformanceMonitor>().RegisterFPSObserver(this);
            this.battleRecord.SimSeed = this.battleController.SimSeed;
            this.battleRecord.ViewTimePassedPreBattle = this.battleController.ViewTimePassedPreBattle;
            this.battleRecord.CombatEncounter         = Service.Get <CombatEncounterController>().GetCurrentCombatEncounter();
            CurrentBattle currentBattle = this.battleController.GetCurrentBattle();

            this.battleRecord.RecordId                  = currentBattle.RecordID;
            this.battleRecord.BattleType                = currentBattle.Type;
            this.battleRecord.AttackerDeploymentData    = BattleDeploymentData.Copy(currentBattle.AttackerDeployableData);
            this.battleRecord.DefenderDeploymentData    = BattleDeploymentData.Copy(currentBattle.DefenderDeployableData);
            this.battleRecord.DefenderGuildTroops       = currentBattle.DefenderGuildTroopsAvailable;
            this.battleRecord.AttackerGuildTroops       = currentBattle.AttackerGuildTroopsAvailable;
            this.battleRecord.LootCreditsAvailable      = currentBattle.LootCreditsAvailable;
            this.battleRecord.LootMaterialsAvailable    = currentBattle.LootMaterialsAvailable;
            this.battleRecord.LootContrabandAvailable   = currentBattle.LootContrabandAvailable;
            this.battleRecord.BuildingLootCreditsMap    = currentBattle.BuildingLootCreditsMap;
            this.battleRecord.BuildingLootMaterialsMap  = currentBattle.BuildingLootMaterialsMap;
            this.battleRecord.BuildingLootContrabandMap = currentBattle.BuildingLootContrabandMap;
            this.battleRecord.DefenderChampions         = currentBattle.DefenderChampionsAvailable;
            this.battleRecord.CmsVersion                = Service.Get <FMS>().GetFileVersion("patches/base.json").ToString();
            this.battleRecord.BattleVersion             = "21.0";
            this.battleRecord.PlanetId                  = currentBattle.PlanetId;
            this.battleRecord.BattleLength              = currentBattle.TimeLeft;
            this.battleRecord.DisabledBuildings         = currentBattle.DisabledBuildings;
            this.battleRecord.victoryConditionsUids     = new List <string>();
            for (int i = 0; i < currentBattle.VictoryConditions.Count; i++)
            {
                this.battleRecord.victoryConditionsUids.Add(currentBattle.VictoryConditions[i].Uid);
            }
            if (currentBattle.FailureCondition != null)
            {
                this.battleRecord.failureConditionUid = currentBattle.FailureCondition.Uid;
            }
            else
            {
                this.battleRecord.failureConditionUid = "";
            }
            this.battleRecord.BattleAttributes.AddDeviceInfo();
            this.battleRecord.DefenseEncounterProfile = currentBattle.DefenseEncounterProfile;
            this.battleRecord.AttackerWarBuffs        = currentBattle.AttackerWarBuffs;
            this.battleRecord.DefenderWarBuffs        = currentBattle.DefenderWarBuffs;
            this.battleRecord.AttackerEquipment       = currentBattle.AttackerEquipment;
            this.battleRecord.DefenderEquipment       = currentBattle.DefenderEquipment;
        }
Beispiel #4
0
 private static void AddBattleProjectileAssets(Map map, BattleTypeVO battle, BattleDeploymentData defensiveWaveData, List <string> attackerWarBuffs, List <string> defenderWarBuffs, List <string> attackerEquipment, List <string> defenderEquipment, List <IAssetVO> assets, IDataController dc)
 {
     if (battle != null)
     {
         ProjectileUtils.AddTroopProjectileAssets(battle.TroopData, assets, dc);
         ProjectileUtils.AddSpecialAttackProjectileAssets(battle.SpecialAttackData, assets, dc);
         ProjectileUtils.AddTroopProjectileAssets(battle.HeroData, assets, dc);
         ProjectileUtils.AddTroopProjectileAssets(battle.ChampionData, assets, dc);
         if (!string.IsNullOrEmpty(battle.EncounterProfile))
         {
             EncounterProfileVO optional = dc.GetOptional <EncounterProfileVO>(battle.EncounterProfile);
             if (optional != null && !string.IsNullOrEmpty(optional.GroupString))
             {
                 string[] array = optional.GroupString.Split(new char[]
                 {
                     '|'
                 });
                 int i   = 0;
                 int num = array.Length;
                 while (i < num)
                 {
                     if (!string.IsNullOrEmpty(array[i]))
                     {
                         string[] array2 = array[i].Split(new char[]
                         {
                             ','
                         });
                         if (array2.Length > 2)
                         {
                             ProjectileUtils.AddTroopProjectileAssets(array2[2], assets, dc);
                         }
                     }
                     i++;
                 }
             }
         }
     }
     if (defensiveWaveData != null)
     {
         ProjectileUtils.AddTroopProjectileAssets(defensiveWaveData.TroopData, assets, dc);
         ProjectileUtils.AddSpecialAttackProjectileAssets(defensiveWaveData.SpecialAttackData, assets, dc);
         ProjectileUtils.AddTroopProjectileAssets(defensiveWaveData.HeroData, assets, dc);
         ProjectileUtils.AddTroopProjectileAssets(defensiveWaveData.ChampionData, assets, dc);
         ProjectileUtils.AddTroopProjectileAssets(defensiveWaveData.SquadData, assets, dc);
     }
     ProjectileUtils.AddWarBuffAssets(attackerWarBuffs, assets, dc);
     ProjectileUtils.AddWarBuffAssets(defenderWarBuffs, assets, dc);
     ProjectileUtils.AddEquipmentAssets(attackerEquipment, assets, dc);
     ProjectileUtils.AddEquipmentAssets(defenderEquipment, assets, dc);
     ProjectileUtils.AddBuildingProjectileAssets(map, assets, dc);
 }
Beispiel #5
0
        protected void InitTroopGrid(string troopGridName, string troopTemplateName, BattleEntry battleEntry)
        {
            this.troopGrid = base.GetElement <UXGrid>(troopGridName);
            this.troopGrid.SetTemplateItem(troopTemplateName);
            if (this.isNonAttackerReplayView)
            {
                battleEntry.SetupExpendedTroops();
            }
            BattleDeploymentData     attackerDeployedData = battleEntry.AttackerDeployedData;
            Dictionary <string, int> dictionary           = null;

            if (attackerDeployedData.SquadData != null)
            {
                dictionary = new Dictionary <string, int>(attackerDeployedData.SquadData);
            }
            this.PopulateExpendedTroops(attackerDeployedData.TroopData, dictionary, false, battleEntry);
            this.PopulateExpendedTroops(dictionary, null, false, battleEntry);
            this.PopulateExpendedTroops(attackerDeployedData.SpecialAttackData, null, true, battleEntry);
            this.PopulateExpendedTroops(attackerDeployedData.HeroData, null, false, battleEntry);
            this.PopulateExpendedTroops(attackerDeployedData.ChampionData, null, false, battleEntry);
            this.troopGrid.RepositionItems();
            this.troopGrid.Scroll(0.5f);
        }
Beispiel #6
0
        public void SetupExpendedTroops()
        {
            IDataController          dataController = Service.Get <IDataController>();
            Dictionary <string, int> dictionary     = new Dictionary <string, int>();
            Dictionary <string, int> dictionary2    = new Dictionary <string, int>();
            Dictionary <string, int> dictionary3    = new Dictionary <string, int>();
            Dictionary <string, int> dictionary4    = new Dictionary <string, int>();
            Dictionary <string, int> dictionary5    = new Dictionary <string, int>();

            if (this.troopsExpended != null)
            {
                foreach (string current in this.troopsExpended.Keys)
                {
                    int         value    = Convert.ToInt32(this.troopsExpended[current], CultureInfo.InvariantCulture);
                    TroopTypeVO optional = dataController.GetOptional <TroopTypeVO>(current);
                    if (optional != null)
                    {
                        TroopType type = optional.Type;
                        if (type != TroopType.Hero)
                        {
                            if (type != TroopType.Champion)
                            {
                                dictionary.Add(current, value);
                            }
                            else
                            {
                                dictionary4.Add(current, value);
                            }
                        }
                        else
                        {
                            dictionary3.Add(current, value);
                        }
                    }
                    else
                    {
                        SpecialAttackTypeVO optional2 = dataController.GetOptional <SpecialAttackTypeVO>(current);
                        if (optional2 != null)
                        {
                            dictionary2.Add(current, value);
                        }
                    }
                }
            }
            if (this.attackerGuildTroopsDeployed != null)
            {
                foreach (string current2 in this.attackerGuildTroopsDeployed.Keys)
                {
                    int         value2    = Convert.ToInt32(this.attackerGuildTroopsDeployed[current2], CultureInfo.InvariantCulture);
                    TroopTypeVO optional3 = dataController.GetOptional <TroopTypeVO>(current2);
                    if (optional3 != null)
                    {
                        dictionary5.Add(current2, value2);
                    }
                }
            }
            this.AttackerDeployedData                   = BattleDeploymentData.CreateEmpty();
            this.AttackerDeployedData.TroopData         = dictionary;
            this.AttackerDeployedData.SpecialAttackData = dictionary2;
            this.AttackerDeployedData.HeroData          = dictionary3;
            this.AttackerDeployedData.ChampionData      = dictionary4;
            this.AttackerDeployedData.SquadData         = dictionary5;
        }
Beispiel #7
0
        private void AddExpendedItems(BattleEntry entry, string entryItemUid, UXGrid expendedGrid)
        {
            BattleDeploymentData            attackerDeployedData            = entry.AttackerDeployedData;
            DeployableShardUnlockController deployableShardUnlockController = Service.DeployableShardUnlockController;

            if (attackerDeployedData == null)
            {
                return;
            }
            Dictionary <string, int> dictionary = null;

            if (attackerDeployedData.SquadData != null)
            {
                dictionary = new Dictionary <string, int>(attackerDeployedData.SquadData);
            }
            if (attackerDeployedData.TroopData != null)
            {
                foreach (KeyValuePair <string, int> current in attackerDeployedData.TroopData)
                {
                    string key = current.Key;
                    int    num = 0;
                    if (dictionary != null && dictionary.ContainsKey(key))
                    {
                        num = dictionary[key];
                        dictionary.Remove(key);
                    }
                    num += current.Value;
                    TroopTypeVO troop       = this.sdc.Get <TroopTypeVO>(key);
                    int         unitQuality = this.GetItemQuality(troop, entry.AttackerEquipment, deployableShardUnlockController);
                    this.AddExpendedItem(expendedGrid, entryItemUid, key, troop, num, unitQuality, entry);
                }
            }
            if (dictionary != null)
            {
                foreach (KeyValuePair <string, int> current2 in dictionary)
                {
                    if (current2.Value >= 1)
                    {
                        TroopTypeVO troopTypeVO = Service.StaticDataController.Get <TroopTypeVO>(current2.Key);
                        int         unitQuality = deployableShardUnlockController.GetUpgradeQualityForDeployable(troopTypeVO);
                        this.AddExpendedItem(expendedGrid, entryItemUid, current2.Key, troopTypeVO, current2.Value, unitQuality, entry);
                    }
                }
            }
            if (attackerDeployedData.SpecialAttackData != null)
            {
                foreach (KeyValuePair <string, int> current3 in attackerDeployedData.SpecialAttackData)
                {
                    string key2  = current3.Key;
                    int    value = current3.Value;
                    SpecialAttackTypeVO specialAttackTypeVO = this.sdc.Get <SpecialAttackTypeVO>(key2);
                    int unitQuality = deployableShardUnlockController.GetUpgradeQualityForDeployable(specialAttackTypeVO);
                    this.AddExpendedItem(expendedGrid, entryItemUid, key2, specialAttackTypeVO, value, unitQuality, entry);
                }
            }
            if (attackerDeployedData.HeroData != null)
            {
                foreach (KeyValuePair <string, int> current4 in attackerDeployedData.HeroData)
                {
                    string      key3        = current4.Key;
                    int         value2      = current4.Value;
                    TroopTypeVO troop2      = this.sdc.Get <TroopTypeVO>(key3);
                    int         unitQuality = this.GetItemQuality(troop2, entry.AttackerEquipment, deployableShardUnlockController);
                    this.AddExpendedItem(expendedGrid, entryItemUid, key3, troop2, value2, unitQuality, entry);
                }
            }
            if (attackerDeployedData.ChampionData != null)
            {
                foreach (KeyValuePair <string, int> current5 in attackerDeployedData.ChampionData)
                {
                    string      key4        = current5.Key;
                    int         value3      = current5.Value;
                    TroopTypeVO troop3      = this.sdc.Get <TroopTypeVO>(key4);
                    int         unitQuality = 0;
                    this.AddExpendedItem(expendedGrid, entryItemUid, key4, troop3, value3, unitQuality, entry);
                }
            }
        }
Beispiel #8
0
        public static List <IAssetVO> GetBattleProjectileAssets(Map map, BattleTypeVO battle, BattleDeploymentData defensiveWaveData, List <string> attackerWarBuffs, List <string> defenderWarBuffs, Dictionary <string, int> defenderSquadTroops, Dictionary <string, int> defenderChampions, List <string> attackerEquipment, List <string> defenderEquipment)
        {
            IDataController dc   = Service.Get <IDataController>();
            List <IAssetVO> list = new List <IAssetVO>();

            if (battle == null || !battle.OverridePlayerUnits)
            {
                Inventory inventory = Service.Get <CurrentPlayer>().Inventory;
                ProjectileUtils.AddTroopProjectileAssets(inventory.Troop, list, dc);
                ProjectileUtils.AddSpecialAttackProjectileAssets(inventory.SpecialAttack, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(inventory.Hero, list, dc);
                ProjectileUtils.AddTroopProjectileAssets(inventory.Champion, list, dc);
            }
            List <SquadDonatedTroop> troops = Service.Get <SquadController>().StateManager.Troops;

            if (troops != null)
            {
                int i     = 0;
                int count = troops.Count;
                while (i < count)
                {
                    ProjectileUtils.AddTroopProjectileAssets(troops[i].TroopUid, list, dc);
                    i++;
                }
            }
            ProjectileUtils.AddTroopProjectileAssets(defenderSquadTroops, list, dc);
            ProjectileUtils.AddTroopProjectileAssets(defenderChampions, list, dc);
            ProjectileUtils.AddBattleProjectileAssets(map, battle, defensiveWaveData, attackerWarBuffs, defenderWarBuffs, attackerEquipment, defenderEquipment, list, dc);
            return(list);
        }