Ejemplo n.º 1
0
        private void ExecuteStart()
        {
            int  armySize1 = this.PlayerSide.CompositionGroup.ArmySize;
            int  armySize2 = this.EnemySide.CompositionGroup.ArmySize;
            bool flag1     = (int)this.GameTypeSelectionGroup.GetCurrentPlayerSide() == 1;
            bool flag2     = this.GameTypeSelectionGroup.GetCurrentPlayerType() == GameTypeSelectionGroup.PlayerType.Commander;
            BasicCharacterObject basicCharacterObject = (BasicCharacterObject)null;

            if (!flag2)
            {
                List <BasicCharacterObject> list = ((IEnumerable <BasicCharacterObject>) this._charactersList).ToList <BasicCharacterObject>();
                list.Remove(this._charactersList[this.PlayerSide.CharacterSelectionGroup.SelectedIndex]);
                list.Remove(this._charactersList[this.EnemySide.CharacterSelectionGroup.SelectedIndex]);
                basicCharacterObject = (BasicCharacterObject)TaleWorlds.Core.Extensions.GetRandomElement <BasicCharacterObject>((IEnumerable <BasicCharacterObject>)list);
                --armySize1;
            }
            int num1  = armySize1 - 1;
            int num2  = (int)Math.Round((double)this.PlayerSide.CompositionGroup.ArmyComposition2Value / 100.0 * (double)num1);
            int num3  = (int)Math.Round((double)this.PlayerSide.CompositionGroup.ArmyComposition3Value / 100.0 * (double)num1);
            int num4  = (int)Math.Round((double)this.PlayerSide.CompositionGroup.ArmyComposition4Value / 100.0 * (double)num1);
            int num5  = num1 - (num2 + num3 + num4);
            int num6  = armySize2 - 1;
            int num7  = (int)Math.Round((double)this.EnemySide.CompositionGroup.ArmyComposition2Value / 100.0 * (double)num6);
            int num8  = (int)Math.Round((double)this.EnemySide.CompositionGroup.ArmyComposition3Value / 100.0 * (double)num6);
            int num9  = (int)Math.Round((double)this.EnemySide.CompositionGroup.ArmyComposition4Value / 100.0 * (double)num6);
            int num10 = num6 - (num7 + num8 + num9);

            CustomBattleCombatant[] customBattleParties = this._customBattleState.GetCustomBattleParties(this._charactersList[this.PlayerSide.CharacterSelectionGroup.SelectedIndex], basicCharacterObject, this._charactersList[this.EnemySide.CharacterSelectionGroup.SelectedIndex], this._factionList[this.PlayerSide.FactionSelectionGroup.SelectedIndex], new int[4]
            {
                num5,
                num2,
                num3,
                num4
            }, new List <BasicCharacterObject>[4]
            {
                this.PlayerSide.CompositionGroup.SelectedMeleeInfantryTypes,
                this.PlayerSide.CompositionGroup.SelectedRangedInfantryTypes,
                this.PlayerSide.CompositionGroup.SelectedMeleeCavalryTypes,
                this.PlayerSide.CompositionGroup.SelectedRangedCavalryTypes
            }, this._factionList[this.EnemySide.FactionSelectionGroup.SelectedIndex], new int[4]
            {
                num10,
                num7,
                num8,
                num9
            }, new List <BasicCharacterObject>[4]
            {
                this.EnemySide.CompositionGroup.SelectedMeleeInfantryTypes,
                this.EnemySide.CompositionGroup.SelectedRangedInfantryTypes,
                this.EnemySide.CompositionGroup.SelectedMeleeCavalryTypes,
                this.EnemySide.CompositionGroup.SelectedRangedCavalryTypes
            }, (flag1 ? 1 : 0) != 0);
            Game.Current.PlayerTroop = this._charactersList[this.PlayerSide.CharacterSelectionGroup.SelectedIndex];
            bool isSiege = this.GameTypeSelectionGroup.GetCurrentGameType() == GameTypeSelectionGroup.GameType.Siege;
            MapSelectionElement selectedMap = this.MapSelectionGroup.SelectedMap;
            MapSelectionElement mapWithName = this.MapSelectionGroup.GetMapWithName(this.MapSelectionGroup.SearchText);

            if (mapWithName != null && mapWithName != selectedMap)
            {
                selectedMap = mapWithName;
            }
            CustomBattleSceneData customBattleSceneData = selectedMap != null ? ((IEnumerable <CustomBattleSceneData>) this._customBattleScenes).Single <CustomBattleSceneData>((Func <CustomBattleSceneData, bool>)(s => ((object)((CustomBattleSceneData)s).Name).ToString() == selectedMap.MapName)) : ((IEnumerable <CustomBattleSceneData>) this._customBattleScenes).First <CustomBattleSceneData>((Func <CustomBattleSceneData, bool>)(cbs => ((CustomBattleSceneData)cbs).IsSiegeMap == isSiege));
            float num11 = 6f;

            if (this.MapSelectionGroup.IsCurrentMapSiege)
            {
                Dictionary <SiegeEngineType, int> dictionary1 = new Dictionary <SiegeEngineType, int>();
                foreach (CustomBattleSiegeMachineVM attackerMeleeMachine in (Collection <CustomBattleSiegeMachineVM>) this._attackerMeleeMachines)
                {
                    if (attackerMeleeMachine.SiegeEngineType != null)
                    {
                        SiegeEngineType siegeWeaponType = CustomBattleMenuVM.GetSiegeWeaponType(attackerMeleeMachine.SiegeEngineType);
                        if (!dictionary1.ContainsKey(siegeWeaponType))
                        {
                            dictionary1.Add(siegeWeaponType, 0);
                        }
                        dictionary1[siegeWeaponType]++;
                    }
                }
                foreach (CustomBattleSiegeMachineVM attackerRangedMachine in (Collection <CustomBattleSiegeMachineVM>) this._attackerRangedMachines)
                {
                    if (attackerRangedMachine.SiegeEngineType != null)
                    {
                        SiegeEngineType siegeWeaponType = CustomBattleMenuVM.GetSiegeWeaponType(attackerRangedMachine.SiegeEngineType);
                        if (!dictionary1.ContainsKey(siegeWeaponType))
                        {
                            dictionary1.Add(siegeWeaponType, 0);
                        }
                        dictionary1[siegeWeaponType]++;
                    }
                }
                Dictionary <SiegeEngineType, int> dictionary2 = new Dictionary <SiegeEngineType, int>();
                foreach (CustomBattleSiegeMachineVM defenderMachine in (Collection <CustomBattleSiegeMachineVM>) this._defenderMachines)
                {
                    if (defenderMachine.SiegeEngineType != null)
                    {
                        SiegeEngineType siegeWeaponType = CustomBattleMenuVM.GetSiegeWeaponType(defenderMachine.SiegeEngineType);
                        if (!dictionary2.ContainsKey(siegeWeaponType))
                        {
                            dictionary2.Add(siegeWeaponType, 0);
                        }
                        dictionary2[siegeWeaponType]++;
                    }
                }
                int     num12;
                float   num13    = (float)(num12 = int.Parse(((Collection <SelectorItemVM>) this.MapSelectionGroup.WallHitpointSelection.ItemList)[this.MapSelectionGroup.WallHitpointSelection.SelectedIndex].StringItem)) / 100f;
                float[] numArray = new float[2];
                if (num12 == 50)
                {
                    int index = MBRandom.RandomInt(2);
                    numArray[index]     = 0.0f;
                    numArray[1 - index] = 1f;
                }
                else
                {
                    numArray[0] = num13;
                    numArray[1] = num13;
                }
                BannerlordMissions.OpenSiegeMissionWithDeployment(((CustomBattleSceneData)customBattleSceneData).SceneID, this._charactersList[this.PlayerSide.CharacterSelectionGroup.SelectedIndex], customBattleParties[0], customBattleParties[1], this.GameTypeSelectionGroup.GetCurrentPlayerType() == GameTypeSelectionGroup.PlayerType.Commander, numArray, ((IEnumerable <CustomBattleSiegeMachineVM>) this._attackerMeleeMachines).Any <CustomBattleSiegeMachineVM>((Func <CustomBattleSiegeMachineVM, bool>)(mm => mm.SiegeEngineType == DefaultSiegeEngineTypes.SiegeTower)), dictionary1, dictionary2, flag1, int.Parse(this.MapSelectionGroup.SceneLevelSelection.GetCurrentItem().StringItem), this.MapSelectionGroup.SeasonSelection.GetCurrentItem().StringItem.ToLower(), this.MapSelectionGroup.IsSallyOutSelected, false, num11);
            }
            else
            {
                BannerlordMissions.OpenCustomBattleMission(((CustomBattleSceneData)customBattleSceneData).SceneID, this._charactersList[this.PlayerSide.CharacterSelectionGroup.SelectedIndex], customBattleParties[0], customBattleParties[1], flag2, basicCharacterObject, "", this.MapSelectionGroup.SeasonSelection.GetCurrentItem().StringItem.ToLower(), num11);
            }
            Debug.Print("P-Ranged: " + (object)num2 + " P-Mounted: " + (object)num3 + " P-HorseArcher: " + (object)num4 + " P-Infantry: " + (object)num5, 0, (Debug.DebugColor) 5, 17592186044416UL);
            Debug.Print("E-Ranged: " + (object)num7 + " E-Mounted: " + (object)num8 + " E-HorseArcher: " + (object)num9 + " E-Infantry: " + (object)num10, 0, (Debug.DebugColor) 5, 17592186044416UL);
            Debug.Print("EXECUTE START - PRESSED", 0, (Debug.DebugColor) 4, 17592186044416UL);
        }
Ejemplo n.º 2
0
        private void ExecuteStart()
        {
            int  armySize1        = this.PlayerSide.CompositionGroup.ArmySize;
            int  armySize2        = this.EnemySide.CompositionGroup.ArmySize;
            bool isPlayerAttacker = this.GameTypeSelectionGroup.GetCurrentPlayerSide() == BattleSideEnum.Attacker;
            bool isPlayerGeneral  = this.GameTypeSelectionGroup.GetCurrentPlayerType() == GameTypeSelectionGroup.PlayerType.Commander;
            BasicCharacterObject playerSideGeneralCharacter = (BasicCharacterObject)null;

            if (!isPlayerGeneral)
            {
                List <BasicCharacterObject> list = this._charactersList.ToList <BasicCharacterObject>();
                list.Remove(this._charactersList[this.PlayerSide.CharacterSelectionGroup.get_SelectedIndex()]);
                list.Remove(this._charactersList[this.EnemySide.CharacterSelectionGroup.get_SelectedIndex()]);
                playerSideGeneralCharacter = list.GetRandomElement <BasicCharacterObject>();
                --armySize1;
            }
            int num1  = armySize1 - 1;
            int num2  = (int)Math.Round((double)this.PlayerSide.CompositionGroup.ArmyComposition2Value / 100.0 * (double)num1);
            int num3  = (int)Math.Round((double)this.PlayerSide.CompositionGroup.ArmyComposition3Value / 100.0 * (double)num1);
            int num4  = (int)Math.Round((double)this.PlayerSide.CompositionGroup.ArmyComposition4Value / 100.0 * (double)num1);
            int num5  = num1 - (num2 + num3 + num4);
            int num6  = armySize2 - 1;
            int num7  = (int)Math.Round((double)this.EnemySide.CompositionGroup.ArmyComposition2Value / 100.0 * (double)num6);
            int num8  = (int)Math.Round((double)this.EnemySide.CompositionGroup.ArmyComposition3Value / 100.0 * (double)num6);
            int num9  = (int)Math.Round((double)this.EnemySide.CompositionGroup.ArmyComposition4Value / 100.0 * (double)num6);
            int num10 = num6 - (num7 + num8 + num9);

            CustomBattleCombatant[] customBattleParties = this._customBattleState.GetCustomBattleParties(this._charactersList[this.PlayerSide.CharacterSelectionGroup.get_SelectedIndex()], playerSideGeneralCharacter, this._charactersList[this.EnemySide.CharacterSelectionGroup.get_SelectedIndex()], this._factionList[this.PlayerSide.FactionSelectionGroup.get_SelectedIndex()], new int[4]
            {
                num5,
                num2,
                num3,
                num4
            }, new List <BasicCharacterObject>[4]
            {
                this.PlayerSide.CompositionGroup.SelectedMeleeInfantryTypes,
                this.PlayerSide.CompositionGroup.SelectedRangedInfantryTypes,
                this.PlayerSide.CompositionGroup.SelectedMeleeCavalryTypes,
                this.PlayerSide.CompositionGroup.SelectedRangedCavalryTypes
            }, this._factionList[this.EnemySide.FactionSelectionGroup.get_SelectedIndex()], new int[4]
            {
                num10,
                num7,
                num8,
                num9
            }, new List <BasicCharacterObject>[4]
            {
                this.EnemySide.CompositionGroup.SelectedMeleeInfantryTypes,
                this.EnemySide.CompositionGroup.SelectedRangedInfantryTypes,
                this.EnemySide.CompositionGroup.SelectedMeleeCavalryTypes,
                this.EnemySide.CompositionGroup.SelectedRangedCavalryTypes
            }, (isPlayerAttacker ? 1 : 0) != 0);
            Game.Current.PlayerTroop = this._charactersList[this.PlayerSide.CharacterSelectionGroup.get_SelectedIndex()];
            bool isSiege = this.GameTypeSelectionGroup.GetCurrentGameType() == GameTypeSelectionGroup.GameType.Siege;
            MapSelectionElement selectedMap = this.MapSelectionGroup.SelectedMap;
            MapSelectionElement mapWithName = this.MapSelectionGroup.GetMapWithName(this.MapSelectionGroup.SearchText);

            if (mapWithName != null && mapWithName != selectedMap)
            {
                selectedMap = mapWithName;
            }
            CustomBattleSceneData customBattleSceneData = selectedMap != null?this._customBattleScenes.Single <CustomBattleSceneData>((Func <CustomBattleSceneData, bool>)(s => s.Name.ToString() == selectedMap.MapName)) : this._customBattleScenes.First <CustomBattleSceneData>((Func <CustomBattleSceneData, bool>)(cbs => cbs.IsSiegeMap == isSiege));

            float timeOfDay = 6f;

            if (this.MapSelectionGroup.IsCurrentMapSiege)
            {
                Dictionary <SiegeEngineType, int> siegeWeaponsCountOfAttackers = new Dictionary <SiegeEngineType, int>();
                foreach (CustomBattleSiegeMachineVM attackerMeleeMachine in (Collection <CustomBattleSiegeMachineVM>) this._attackerMeleeMachines)
                {
                    if (attackerMeleeMachine.SiegeEngineType != null)
                    {
                        SiegeEngineType siegeWeaponType = CustomBattleMenuVM.GetSiegeWeaponType(attackerMeleeMachine.SiegeEngineType);
                        if (!siegeWeaponsCountOfAttackers.ContainsKey(siegeWeaponType))
                        {
                            siegeWeaponsCountOfAttackers.Add(siegeWeaponType, 0);
                        }
                        siegeWeaponsCountOfAttackers[siegeWeaponType]++;
                    }
                }
                foreach (CustomBattleSiegeMachineVM attackerRangedMachine in (Collection <CustomBattleSiegeMachineVM>) this._attackerRangedMachines)
                {
                    if (attackerRangedMachine.SiegeEngineType != null)
                    {
                        SiegeEngineType siegeWeaponType = CustomBattleMenuVM.GetSiegeWeaponType(attackerRangedMachine.SiegeEngineType);
                        if (!siegeWeaponsCountOfAttackers.ContainsKey(siegeWeaponType))
                        {
                            siegeWeaponsCountOfAttackers.Add(siegeWeaponType, 0);
                        }
                        siegeWeaponsCountOfAttackers[siegeWeaponType]++;
                    }
                }
                Dictionary <SiegeEngineType, int> siegeWeaponsCountOfDefenders = new Dictionary <SiegeEngineType, int>();
                foreach (CustomBattleSiegeMachineVM defenderMachine in (Collection <CustomBattleSiegeMachineVM>) this._defenderMachines)
                {
                    if (defenderMachine.SiegeEngineType != null)
                    {
                        SiegeEngineType siegeWeaponType = CustomBattleMenuVM.GetSiegeWeaponType(defenderMachine.SiegeEngineType);
                        if (!siegeWeaponsCountOfDefenders.ContainsKey(siegeWeaponType))
                        {
                            siegeWeaponsCountOfDefenders.Add(siegeWeaponType, 0);
                        }
                        siegeWeaponsCountOfDefenders[siegeWeaponType]++;
                    }
                }
                int     num11;
                float   num12 = (float)(num11 = int.Parse(this.MapSelectionGroup.WallHitpointSelection.get_ItemList()[this.MapSelectionGroup.WallHitpointSelection.get_SelectedIndex()].get_StringItem())) / 100f;
                float[] wallHitPointPercentages = new float[2];
                if (num11 == 50)
                {
                    int index = MBRandom.RandomInt(2);
                    wallHitPointPercentages[index]     = 0.0f;
                    wallHitPointPercentages[1 - index] = 1f;
                }
                else
                {
                    wallHitPointPercentages[0] = num12;
                    wallHitPointPercentages[1] = num12;
                }
                BannerlordMissions.OpenSiegeMissionWithDeployment(customBattleSceneData.SceneID, this._charactersList[this.PlayerSide.CharacterSelectionGroup.get_SelectedIndex()], customBattleParties[0], customBattleParties[1], this.GameTypeSelectionGroup.GetCurrentPlayerType() == GameTypeSelectionGroup.PlayerType.Commander, wallHitPointPercentages, this._attackerMeleeMachines.Any <CustomBattleSiegeMachineVM>((Func <CustomBattleSiegeMachineVM, bool>)(mm => mm.SiegeEngineType == DefaultSiegeEngineTypes.SiegeTower)), siegeWeaponsCountOfAttackers, siegeWeaponsCountOfDefenders, isPlayerAttacker, int.Parse(this.MapSelectionGroup.SceneLevelSelection.GetCurrentItem().get_StringItem()), this.MapSelectionGroup.SeasonSelection.GetCurrentItem().get_StringItem().ToLower(), this.MapSelectionGroup.IsSallyOutSelected, false, timeOfDay);
            }
            else
            {
                BannerlordMissions.OpenCustomBattleMission(customBattleSceneData.SceneID, this._charactersList[this.PlayerSide.CharacterSelectionGroup.get_SelectedIndex()], customBattleParties[0], customBattleParties[1], isPlayerGeneral, playerSideGeneralCharacter, "", this.MapSelectionGroup.SeasonSelection.GetCurrentItem().get_StringItem().ToLower(), timeOfDay);
            }
            Debug.Print("P-Ranged: " + (object)num2 + " P-Mounted: " + (object)num3 + " P-HorseArcher: " + (object)num4 + " P-Infantry: " + (object)num5, 0, Debug.DebugColor.Blue, 17592186044416UL);
            Debug.Print("E-Ranged: " + (object)num7 + " E-Mounted: " + (object)num8 + " E-HorseArcher: " + (object)num9 + " E-Infantry: " + (object)num10, 0, Debug.DebugColor.Blue, 17592186044416UL);
            Debug.Print("EXECUTE START - PRESSED", 0, Debug.DebugColor.Green, 17592186044416UL);
        }