| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获得自定义队伍中各个国家的武将数量 |
| | | /// </summary> |
| | | public Dictionary<HeroCountry, int> GetCountryHeroCountByTeamHeroList(List<TeamHero> teamHeroes) |
| | | { |
| | | Dictionary<HeroCountry, int> heroCountryCount = new Dictionary<HeroCountry, int>(); |
| | | if (teamHeroes == null) |
| | | { |
| | | return heroCountryCount; |
| | | } |
| | | for (int i = 0; i < teamHeroes.Count; i++) |
| | | { |
| | | if (teamHeroes[i] == null) |
| | | continue; |
| | | var country = teamHeroes[i].Country; |
| | | |
| | | if (!heroCountryCount.ContainsKey(country)) |
| | | { |
| | | heroCountryCount.Add(country, 1); |
| | | } |
| | | else |
| | | { |
| | | heroCountryCount[country] += 1; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | return heroCountryCount; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获得上阵中武将数量最大的国家和数量 |
| | | /// </summary> |
| | | /// <param name="teamType"></param> |
| | |
| | | public Int2 GetMaxCountHeroCountry(TeamType teamType, bool isPreview = false) |
| | | { |
| | | var countryCountDict = GetCountryHeroCountByTeamType(teamType, isPreview); |
| | | //找到最大的国家和数量 |
| | | HeroCountry country = HeroCountry.None; |
| | | int maxValue = 0; |
| | | foreach (var data in countryCountDict) |
| | | { |
| | | if (data.Value > maxValue) |
| | | { |
| | | country = data.Key; |
| | | maxValue = data.Value; |
| | | } |
| | | } |
| | | return new Int2((int)country, maxValue); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获得自定义队伍中武将数量最大的国家和数量 |
| | | /// </summary> |
| | | public Int2 GetMaxCountHeroCountry(List<TeamHero> teamType) |
| | | { |
| | | var countryCountDict = GetCountryHeroCountByTeamHeroList(teamType); |
| | | //找到最大的国家和数量 |
| | | HeroCountry country = HeroCountry.None; |
| | | int maxValue = 0; |
| | |
| | | //推荐阵容 |
| | | public List<string> SelectRecommend() |
| | | { |
| | | //推荐阵容的算法逻辑 |
| | | //自动选择优先级:武将等级>突破等级>武将觉醒阶级>武将品质>武将吞噬星级>武将ID |
| | | var tmpList = HeroManager.Instance.GetHeroGuidList(); |
| | | tmpList.Sort(CmpHeroRecommend); |
| | | |
| | | |
| | | //推荐最多6个,存在相同heroid,则跳过 |
| | | List<string> selectHeroList = new List<string>(); |
| | | List<int> selectHeroIDList = new List<int>(); |
| | |
| | | string guid = tmpList[i]; |
| | | HeroInfo heroInfo = HeroManager.Instance.GetHero(guid); |
| | | if (selectHeroIDList.Contains(heroInfo.heroId)) |
| | | //重复英雄 |
| | | continue; |
| | | //如果重复了,跳过 |
| | | if (selectHeroList.Contains(guid)) |
| | |
| | | selectHeroList.Add(guid); |
| | | selectHeroIDList.Add(heroInfo.heroId); |
| | | } |
| | | |
| | | // 再按 肉盾>控制>输出>辅助 |
| | | selectHeroList.Sort(CmpByJob); |
| | | |
| | | return selectHeroList; |
| | | } |
| | | |
| | | |
| | | //!!!新排序规则 |
| | | //若在新手引导(引导ID)中,如果5号位为空,则优先放置5号位 |
| | | //按战力排序 |
| | | int CmpHeroRecommend(string guidA, string guidB) |
| | | { |
| | | HeroInfo heroA = HeroManager.Instance.GetHero(guidA); |
| | |
| | | return 0; |
| | | } |
| | | |
| | | // 排序规则:武将等级>突破等级>武将觉醒阶级>武将品质>武将吞噬星级>武将ID |
| | | if (heroA.heroLevel != heroB.heroLevel) |
| | | { |
| | | return heroA.heroLevel > heroB.heroLevel ? -1 : 1; |
| | | } |
| | | if (heroA.breakLevel != heroB.breakLevel) |
| | | { |
| | | return heroA.breakLevel > heroB.breakLevel ? -1 : 1; |
| | | } |
| | | if (heroA.awakeLevel != heroB.awakeLevel) |
| | | { |
| | | return heroA.awakeLevel > heroB.awakeLevel ? -1 : 1; |
| | | } |
| | | if (heroA.Quality != heroB.Quality) |
| | | { |
| | | return heroA.Quality > heroB.Quality ? -1 : 1; |
| | | } |
| | | if (heroA.heroStar != heroB.heroStar) |
| | | { |
| | | return heroA.heroStar > heroB.heroStar ? -1 : 1; |
| | | } |
| | | // // 排序规则:武将等级>突破等级>武将觉醒阶级>武将品质>武将吞噬星级>武将ID |
| | | // if (heroA.heroLevel != heroB.heroLevel) |
| | | // { |
| | | // return heroA.heroLevel > heroB.heroLevel ? -1 : 1; |
| | | // } |
| | | // if (heroA.breakLevel != heroB.breakLevel) |
| | | // { |
| | | // return heroA.breakLevel > heroB.breakLevel ? -1 : 1; |
| | | // } |
| | | // if (heroA.awakeLevel != heroB.awakeLevel) |
| | | // { |
| | | // return heroA.awakeLevel > heroB.awakeLevel ? -1 : 1; |
| | | // } |
| | | // if (heroA.Quality != heroB.Quality) |
| | | // { |
| | | // return heroA.Quality > heroB.Quality ? -1 : 1; |
| | | // } |
| | | // if (heroA.heroStar != heroB.heroStar) |
| | | // { |
| | | // return heroA.heroStar > heroB.heroStar ? -1 : 1; |
| | | // } |
| | | |
| | | return heroA.heroId.CompareTo(heroB.heroId); |
| | | |
| | | |
| | | return heroB.CalculateFightPower(false).CompareTo(heroA.CalculateFightPower(false)); |
| | | } |
| | | |
| | | int CmpByJob(string guidA, string guidB) |
| | | { |
| | | HeroInfo heroA = HeroManager.Instance.GetHero(guidA); |
| | | HeroInfo heroB = HeroManager.Instance.GetHero(guidB); |
| | | if (heroA == null || heroB == null) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | int indexA = Array.IndexOf(teamSortByJob, heroA.heroConfig.Class); |
| | | int indexB = Array.IndexOf(teamSortByJob, heroB.heroConfig.Class); |
| | | |
| | | return indexA.CompareTo(indexB); |
| | | } |
| | | |
| | | |
| | |
| | | public int[][] lockHeroCountLimit; |
| | | public List<int> lockIndexList = new List<int>(); |
| | | |
| | | public int[] teamSortByJob; |
| | | public int onekeyGuideID; |
| | | public int[] onekeyGuidePosList; //一键上阵在引导下的顺序 |
| | | |
| | | public Action OnUnLockHeroCountEvent; |
| | | public int lockState |
| | | { |