// Helpers.MobilePartyHelper public static FlattenedTroopRoster GetStrongestAndPriorTroops(MobileParty mobileParty, int maxTroopCount, List <Hero> includeList) { TroopRoster troopRoster = TroopRoster.CreateDummyTroopRoster(); FlattenedTroopRoster memberRoster = mobileParty.MemberRoster.ToFlattenedRoster(); memberRoster.RemoveIf((x) => x.IsWounded); List <CharacterObject> list = memberRoster.Select((x) => x.Troop).OrderByDescending((x) => x.Level).ToList <CharacterObject>(); if (null != includeList && includeList.Count > 0) { foreach (Hero hero in includeList) { if (list.Any((x) => x == hero.CharacterObject)) { list.Remove(hero.CharacterObject); troopRoster.AddToCounts(hero.CharacterObject, 1, false, 0, 0, true, -1); maxTroopCount--; } } } List <CharacterObject> heroList = list.Where((x) => x.IsHero).ToList <CharacterObject>(); int num = Math.Min(heroList.Count <CharacterObject>(), maxTroopCount); for (int i = 0; i < num; i++) { troopRoster.AddToCounts(heroList[i], 1, false, 0, 0, true, -1); list.Remove(heroList[i]); } return(troopRoster.ToFlattenedRoster()); }
private void SelectMainPartyMember(MenuCallbackArgs args, Action nextStep, int maxNum) { if (null == this._tempMainMobile) { this._tempMainMobile = MBObjectManager.Instance.CreateObject <MobileParty>("sms_sneak_temp_party"); } else { this._tempMainMobile.MemberRoster.Reset(); } int count = MobileParty.MainParty.MemberRoster.Count; TroopRoster strongestTroopRoster = TroopRoster.CreateDummyTroopRoster(); List <Hero> includeHeros = new List <Hero>(); includeHeros.Add(Hero.MainHero); FlattenedTroopRoster strongestAndPriorTroops = GameComponent.GetStrongestAndPriorTroops(MobileParty.MainParty, maxNum, includeHeros); strongestTroopRoster.Add(strongestAndPriorTroops); bool execueted = OpenSlelectTroops(args, strongestTroopRoster, maxNum, new Func <CharacterObject, bool>(this.CanChangeStatusOfTroop), new Action <TroopRoster>((troop) => { DealPatyTroop(troop); nextStep(); })); if (!execueted) { //如果没有执行,就走随机筛选 TroopRoster troopRosters = MobileParty.MainParty.MemberRoster; List <TroopRosterElement> list = troopRosters.GetTroopRoster(); TroopRoster battleTroopRoster = TroopRoster.CreateDummyTroopRoster(); foreach (TroopRosterElement element in list) { if (element.Character.IsHero && !element.Character.IsPlayerCharacter) { if (battleTroopRoster.Count < maxNum) { battleTroopRoster.AddToCounts(element.Character, element.Number); } } } ; DealPatyTroop(battleTroopRoster); nextStep(); } }