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); }
public CustomBattleMenuVM(CustomBattleState battleState) { ////this.\u002Ector(); this._customBattleState = battleState; List <BasicCultureObject> basicCultureObjectList = new List <BasicCultureObject>(); basicCultureObjectList.Add((BasicCultureObject)Game.Current.ObjectManager.GetObject <BasicCultureObject>("empire")); basicCultureObjectList.Add((BasicCultureObject)Game.Current.ObjectManager.GetObject <BasicCultureObject>("sturgia")); basicCultureObjectList.Add((BasicCultureObject)Game.Current.ObjectManager.GetObject <BasicCultureObject>("aserai")); basicCultureObjectList.Add((BasicCultureObject)Game.Current.ObjectManager.GetObject <BasicCultureObject>("vlandia")); basicCultureObjectList.Add((BasicCultureObject)Game.Current.ObjectManager.GetObject <BasicCultureObject>("battania")); basicCultureObjectList.Add((BasicCultureObject)Game.Current.ObjectManager.GetObject <BasicCultureObject>("khuzait")); this._factionList = basicCultureObjectList; this._customBattleScenes = new List <CustomBattleSceneData>(); List <BasicCharacterObject> basicCharacterObjectList = new List <BasicCharacterObject>(); basicCharacterObjectList.Add((BasicCharacterObject)Game.Current.ObjectManager.GetObject <BasicCharacterObject>("commander_1")); basicCharacterObjectList.Add((BasicCharacterObject)Game.Current.ObjectManager.GetObject <BasicCharacterObject>("commander_2")); basicCharacterObjectList.Add((BasicCharacterObject)Game.Current.ObjectManager.GetObject <BasicCharacterObject>("commander_3")); basicCharacterObjectList.Add((BasicCharacterObject)Game.Current.ObjectManager.GetObject <BasicCharacterObject>("commander_4")); basicCharacterObjectList.Add((BasicCharacterObject)Game.Current.ObjectManager.GetObject <BasicCharacterObject>("commander_5")); basicCharacterObjectList.Add((BasicCharacterObject)Game.Current.ObjectManager.GetObject <BasicCharacterObject>("commander_6")); basicCharacterObjectList.Add((BasicCharacterObject)Game.Current.ObjectManager.GetObject <BasicCharacterObject>("commander_7")); this._charactersList = basicCharacterObjectList; this.EnemySide = new CustomBattleMenuSideVM(new TextObject("{=35IHscBa}ENEMY", (Dictionary <string, TextObject>)null), false); this.PlayerSide = new CustomBattleMenuSideVM(new TextObject("{=BC7n6qxk}PLAYER", (Dictionary <string, TextObject>)null), true); List <string> stringList = new List <string>(); List <string> list = ((IEnumerable <BasicCultureObject>) this._factionList).Select <BasicCultureObject, string>((Func <BasicCultureObject, string>)(f => ((object)f.Name).ToString())).ToList <string>(); this.EnemySide.FactionSelectionGroup.Refresh((IEnumerable <string>)list, 0, new Action <SelectorVM <SelectorItemVM> >(this.OnEnemyFactionSelection)); this.PlayerSide.FactionSelectionGroup.Refresh((IEnumerable <string>)list, 0, new Action <SelectorVM <SelectorItemVM> >(this.OnPlayerFactionSelection)); this.IsAttackerCustomMachineSelectionEnabled = false; List <MapSelectionElement> elementList = new List <MapSelectionElement>(); this._customBattleScenes = CustomGame.Current.CustomBattleScenes.ToList <CustomBattleSceneData>(); using (List <CustomBattleSceneData> .Enumerator enumerator = this._customBattleScenes.GetEnumerator()) { while (enumerator.MoveNext()) { CustomBattleSceneData current = enumerator.Current; elementList.Add(new MapSelectionElement((current.Name).ToString(), ((CustomBattleSceneData)current).IsSiegeMap, ((CustomBattleSceneData)current).IsVillageMap)); } } this.MapSelectionGroup = new MapSelectionGroup(((object)new TextObject("{=fXhblsky}MAP", (Dictionary <string, TextObject>)null)).ToString(), elementList); this.PlayerSide.CharacterSelectionGroup.Refresh((IEnumerable <string>)((IEnumerable <BasicCharacterObject>) this._charactersList).Select <BasicCharacterObject, string>((Func <BasicCharacterObject, string>)(p => ((object)p.Name).ToString())).ToList <string>(), 0, new Action <SelectorVM <SelectorItemVM> >(this.OnPlayerCharacterSelection)); this.EnemySide.CharacterSelectionGroup.Refresh((IEnumerable <string>)((IEnumerable <BasicCharacterObject>) this._charactersList).Select <BasicCharacterObject, string>((Func <BasicCharacterObject, string>)(p => ((object)p.Name).ToString())).ToList <string>(), 1, new Action <SelectorVM <SelectorItemVM> >(this.OnEnemyCharacterSelection)); this.OnPlayerCharacterSelection(this.PlayerSide.CharacterSelectionGroup); this.OnEnemyCharacterSelection(this.EnemySide.CharacterSelectionGroup); this.AttackerMeleeMachines = new MBBindingList <CustomBattleSiegeMachineVM>(); for (int index = 0; index < 3; ++index) { ((Collection <CustomBattleSiegeMachineVM>) this.AttackerMeleeMachines).Add(new CustomBattleSiegeMachineVM((SiegeEngineType)null, new Action <CustomBattleSiegeMachineVM>(this.OnMeleeMachineSelection))); } this.AttackerRangedMachines = new MBBindingList <CustomBattleSiegeMachineVM>(); for (int index = 0; index < 4; ++index) { ((Collection <CustomBattleSiegeMachineVM>) this.AttackerRangedMachines).Add(new CustomBattleSiegeMachineVM((SiegeEngineType)null, new Action <CustomBattleSiegeMachineVM>(this.OnAttackerRangedMachineSelection))); } this.DefenderMachines = new MBBindingList <CustomBattleSiegeMachineVM>(); for (int index = 0; index < 4; ++index) { ((Collection <CustomBattleSiegeMachineVM>) this.DefenderMachines).Add(new CustomBattleSiegeMachineVM((SiegeEngineType)null, new Action <CustomBattleSiegeMachineVM>(this.OnDefenderRangedMachineSelection))); } this.GameTypeSelectionGroup = new GameTypeSelectionGroup("Game Type", this.MapSelectionGroup, new Action <bool>(this.OnPlayerTypeChange)); base.RefreshValues(); }
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); }