From bae41593e19d32046f77ed1f036089e015380b99 Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期三, 30 七月 2025 22:25:18 +0800 Subject: [PATCH] 117 【武将】武将系统 - 布阵临时版 --- Main/System/HeroUI/HeroUIManager.cs | 107 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 97 insertions(+), 10 deletions(-) diff --git a/Main/System/HeroUI/HeroUIManager.cs b/Main/System/HeroUI/HeroUIManager.cs index f36047c..1efeaae 100644 --- a/Main/System/HeroUI/HeroUIManager.cs +++ b/Main/System/HeroUI/HeroUIManager.cs @@ -1,6 +1,7 @@ 锘縰sing System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Text; using UnityEngine; @@ -8,12 +9,11 @@ //姝﹀皢鐩稿叧鐣岄潰鐨勬搷浣滄暟鎹鐞� public class HeroUIManager : GameSystemManager<HeroUIManager> { - //姝﹀皢鍒楄〃鐣岄潰 + #region 姝﹀皢鍒楄〃鐣岄潰 public List<string> heroSortList { get; private set; } = new List<string>(); //涓婇樀涓轰富绾跨殑鍒楄〃 + #endregion - public List<string> heroOnTeamSortList { get; private set; } = new List<string>(); //涓嶅悓涓婇樀鐨勫垪琛ㄦ帓搴� - public TeamType selectTeamType = TeamType.Story; //褰撳墠閫変腑鐨勬槸鍝釜闃靛, 甯冮樀鐩稿叧閫昏緫浣跨敤 public void OnBeforePlayerDataInitialize() { @@ -35,8 +35,12 @@ } - public bool waitResortHeroList = false; + + public void QueryUnLockHeroPack() + { + //瑙i攣鏇村鐨勬灏嗚儗鍖� + } //鍒锋柊鏃舵満, 鎵撳紑姝﹀皢鐣岄潰 鎴栬�� 鍏抽棴鍔熻兘鐣岄潰 public void SortHeroList() @@ -86,10 +90,21 @@ return heroA.heroId.CompareTo(heroB.heroId); } + #region 甯冮樀鐣岄潰 + public List<string> heroOnTeamSortList { get; private set; } = new List<string>(); //涓嶅悓涓婇樀鐨勫垪琛ㄦ帓搴� + + public TeamType selectTeamType = TeamType.Story; //褰撳墠閫変腑鐨勬槸鍝釜闃靛, 甯冮樀鐩稿叧閫昏緫浣跨敤 + public int selectTeamPosJob = 0; //甯冮樀鐣岄潰 绛涢�夎亴涓� + public int selectTeamPosCountry = 0; //甯冮樀鐣岄潰 绛涢�夊浗瀹� + + public const float clickFlyPosTime = 0.5f; //鐐瑰嚮鍒楄〃涓殑姝﹀皢鍥炬爣鏃�, 椋炲叆甯冮樀鐨勬椂闂� + + public event Action<List<int>, int, Vector3> OnTeamPosChangeEvent; //甯冮樀鍙樺寲 浣嶇疆锛屽垪琛ㄧ殑璧烽绱㈠紩锛岃捣椋炲潗鏍� + public void SortHeroOnTeamList() { - heroOnTeamSortList = HeroManager.Instance.GetHeroGuidList(); + heroOnTeamSortList = HeroManager.Instance.GetHeroGuidList(selectTeamPosJob, selectTeamPosCountry); heroOnTeamSortList.Sort(CmpHeroByTeamType); } @@ -136,10 +151,6 @@ - public void QueryUnLockHeroPack() - { - //瑙i攣鏇村鐨勬灏嗚儗鍖� - } //涓婇樀闃熶紞涓悇涓浗瀹剁殑姝﹀皢鏁伴噺 public Dictionary<HeroCountry, int> GetCountryHeroCountByTeamType(TeamType teamType) @@ -151,6 +162,8 @@ { for (int i = 0; i < team.serverHeroes.Length; i++) { + if (team.serverHeroes[i] == null) + continue; var hero = HeroManager.Instance.GetHero(team.serverHeroes[i].guid); if (hero != null) { @@ -197,7 +210,81 @@ return AttackType == 0 ? (int)TeamType.Arena : (int)TeamType.ArenaDefense; } - + return (int)TeamType.Story; } + + + public void NotifyOnTeamPosChangeEvent(List<int> posList, int flyIndex, Vector3 startPos) + { + OnTeamPosChangeEvent?.Invoke(posList, flyIndex, startPos); + } + + //鎺ㄨ崘闃靛 + public List<string> SelectRecommend() + { + //鎺ㄨ崘闃靛鐨勭畻娉曢�昏緫 + //鑷姩閫夋嫨浼樺厛绾э細姝﹀皢绛夌骇锛炵獊鐮寸瓑绾э紴姝﹀皢瑙夐啋闃剁骇锛炴灏嗗搧璐紴姝﹀皢鍚炲櫖鏄熺骇锛炴灏咺D + var tmpList = HeroManager.Instance.GetHeroGuidList(); + tmpList.Sort(CmpHeroByTeamType); + + + //鎺ㄨ崘鏈�澶�6涓紝瀛樺湪鐩稿悓heroid锛屽垯璺宠繃 + List<string> selectHeroList = new List<string>(); + List<int> selectHeroIDList = new List<int>(); + for (int i = 0; i < tmpList.Count; i++) + { + if (selectHeroList.Count >= TeamConst.MaxTeamHeroCount) + break; + + string guid = tmpList[i]; + HeroInfo heroInfo = HeroManager.Instance.GetHero(guid); + if (selectHeroIDList.Contains(heroInfo.heroId)) + continue; + //濡傛灉閲嶅浜�,璺宠繃 + if (selectHeroList.Contains(guid)) + continue; + selectHeroList.Add(guid); + selectHeroIDList.Add(heroInfo.heroId); + } + return selectHeroList; + } + + + int CmpHeroRecommend(string guidA, string guidB) + { + HeroInfo heroA = HeroManager.Instance.GetHero(guidA); + HeroInfo heroB = HeroManager.Instance.GetHero(guidB); + if (heroA == null || heroB == null) + { + 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 != heroA.heroStar) + { + return heroA.heroStar > heroB.heroStar ? -1 : 1; + } + + return heroA.heroId.CompareTo(heroB.heroId); + } + + + #endregion } -- Gitblit v1.8.0