From 39001a600fcae2bcf27c225df8752d75fb92fef4 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 31 十月 2025 11:18:26 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts

---
 Main/System/HeroUI/HeroUIManager.OnTeam.cs |  284 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 254 insertions(+), 30 deletions(-)

diff --git a/Main/System/HeroUI/HeroUIManager.OnTeam.cs b/Main/System/HeroUI/HeroUIManager.OnTeam.cs
index 6a5846a..73d39ac 100644
--- a/Main/System/HeroUI/HeroUIManager.OnTeam.cs
+++ b/Main/System/HeroUI/HeroUIManager.OnTeam.cs
@@ -6,7 +6,7 @@
 
 public partial class HeroUIManager : GameSystemManager<HeroUIManager>
 {
-    
+
 
     #region 甯冮樀鐣岄潰
     public List<string> heroOnTeamSortList { get; private set; } = new List<string>();    //涓嶅悓涓婇樀鐨勫垪琛ㄦ帓搴�
@@ -171,12 +171,43 @@
 
         var team = TeamManager.Instance.GetTeam(teamType);
         if (team == null)
-        { 
+        {
             return heroCountryCount;
         }
         TeamHero[] teamHeroes = isPreview ? team.tempHeroes : team.serverHeroes;
 
         for (int i = 0; i < teamHeroes.Length; 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>
+    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;
@@ -220,6 +251,26 @@
         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;
+        foreach (var data in countryCountDict)
+        {
+            if (data.Value > maxValue)
+            {
+                country = data.Key;
+                maxValue = data.Value;
+            }
+        }
+        return new Int2((int)country, maxValue);
+    }
+
     //鍦ㄤ笉鍚岄〉绛句笅閫堿ttackType 0 鏀诲嚮闃靛 1 闃插畧闃靛
     public int GetSelectTeamTypeByAttackType(int AttackType)
     {
@@ -241,12 +292,8 @@
     //鎺ㄨ崘闃靛
     public List<string> SelectRecommend()
     {
-        //鎺ㄨ崘闃靛鐨勭畻娉曢�昏緫
-        //鑷姩閫夋嫨浼樺厛绾э細姝﹀皢绛夌骇锛炵獊鐮寸瓑绾э紴姝﹀皢瑙夐啋闃剁骇锛炴灏嗗搧璐紴姝﹀皢鍚炲櫖鏄熺骇锛炴灏咺D
         var tmpList = HeroManager.Instance.GetHeroGuidList();
         tmpList.Sort(CmpHeroRecommend);
-
-
         //鎺ㄨ崘鏈�澶�6涓紝瀛樺湪鐩稿悓heroid锛屽垯璺宠繃
         List<string> selectHeroList = new List<string>();
         List<int> selectHeroIDList = new List<int>();
@@ -258,6 +305,7 @@
             string guid = tmpList[i];
             HeroInfo heroInfo = HeroManager.Instance.GetHero(guid);
             if (selectHeroIDList.Contains(heroInfo.heroId))
+                //閲嶅鑻遍泟
                 continue;
             //濡傛灉閲嶅浜�,璺宠繃
             if (selectHeroList.Contains(guid))
@@ -265,10 +313,16 @@
             selectHeroList.Add(guid);
             selectHeroIDList.Add(heroInfo.heroId);
         }
+
+        // 鍐嶆寜 鑲夌浘>鎺у埗>杈撳嚭>杈呭姪
+        selectHeroList.Sort(CmpByJob);
+
         return selectHeroList;
     }
 
-
+    //锛侊紒锛佹柊鎺掑簭瑙勫垯
+    //鑻ュ湪鏂版墜寮曞锛堝紩瀵糏D锛変腑锛屽鏋�5鍙蜂綅涓虹┖锛屽垯浼樺厛鏀剧疆5鍙蜂綅
+    //鎸夋垬鍔涙帓搴� 
     int CmpHeroRecommend(string guidA, string guidB)
     {
         HeroInfo heroA = HeroManager.Instance.GetHero(guidA);
@@ -278,34 +332,204 @@
             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);
     }
 
 
     #endregion
 
-    
+    #region 涓荤晫闈笂鐨勬灏嗕笂闃佃В閿佹樉绀� 鍜� 瑙i攣瑙勫垯
+
+    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
+    {
+        get
+        {
+            return QuickSetting.Instance.GetQuickSettingValue<int>(QuickSettingType.HeroCountLock, 0);
+        }
+        set
+        {
+            QuickSetting.Instance.SetQuickSetting(QuickSettingType.HeroCountLock, value, 0);
+            QuickSetting.Instance.SendPackage();
+            RefreshServerLockIndex();
+        }
+    }
+
+    //瑙i攣涓婇樀鑻遍泟鐨勬暟閲忛檺鍒�, 瑙i攣鏉′欢鍦ㄧ晫闈笂鏄寜椤哄簭鎺掑簭鐨勶紝浣嗘槸閿佸畾鐨勪綅缃槸鍔ㄦ�佸彉鍖栫殑
+    //姣斿 绗�4锛�5锛�6鏍煎瓙閿佷綇浜嗭紝浣嗙6涓殑閿佸厛瀹屾垚浜嗚В閿佹潯浠讹紝瑙i攣鍚庨攣浣忕殑浣嶇疆寰�鍚庨『鎺�
+    //鍒� 绗�4鐨勪綅缃樉绀轰负瑙i攣鐘舵�侊紝5鍜�6鏄攣浣忕姸鎬侊紝5鐨勮В閿佹潯浠舵寜閰嶇疆鍒楄〃鐨勯『搴忚В閿侊紙鍗充负鍘�4鐨勮В閿佹潯浠讹級
+
+    // 妯℃嫙鏈嶅姟绔� 杩欓噷鐨刬ndex 瀵瑰簲鐨勬槸閰嶈〃鐨�
+    public bool IsUnLock(int configIndex)
+    {
+        //鎸塴ockState鐨勪綅鍒ゆ柇
+        return (lockState & (1 << configIndex)) != 0;
+    }
+
+    public bool SetUnLock(int configIndex)
+    {
+        if (!CanUnLock(configIndex, true))
+        {
+            return false;
+        }
+        lockState |= 1 << configIndex;
+        return true;
+    }
+
+    // 瑙i攣绫诲瀷
+    // 1.涓诲叕绛夌骇杈綳绾у紑鍚紱
+    // 2.閫氬叧涓荤嚎X-X寮�鍚紱鍚屼换鍔¢厤娉�
+    // 3.寮�鏈嶆椂闂磋揪鍒癤澶╁紑鍚紱
+    public bool CanUnLock(int configIndex, bool notify = false)
+    {
+        int type = lockHeroCountLimit[configIndex][0];
+        int value = lockHeroCountLimit[configIndex][1];
+        if (type == 1)
+        {
+            if (PlayerDatas.Instance.baseData.LV < value)
+            {
+                if (notify)
+                    SysNotifyMgr.Instance.ShowTip("HeroCountUnLock1", value);
+                return false;
+            }
+        }
+        else if (type == 2)
+        {
+            //濡侲xAttr1鍊间负20103浠h〃褰撳墠宸茬粡杩囦簡绗�2绔犵1鍏崇3娉紱 value涓�201
+            if (PlayerDatas.Instance.baseData.ExAttr1 / 100 <= value)
+            {
+                if (notify)
+                    SysNotifyMgr.Instance.ShowTip("HeroCountUnLock2", value / 100, value % 100);
+                return false;
+            }
+        }
+        else if (type == 3)
+        {
+            if (TimeUtility.OpenDay < value - 1)
+            {
+                if (notify)
+                    SysNotifyMgr.Instance.ShowTip("HeroCountUnLock3", value);
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+
+    public void ShowUnLockTip(int configIndex)
+    {
+        int type = lockHeroCountLimit[configIndex][0];
+        int value = lockHeroCountLimit[configIndex][1];
+        if (type == 1)
+        {
+            if (PlayerDatas.Instance.baseData.LV < value)
+            {
+                SysNotifyMgr.Instance.ShowTip("HeroCountUnLock1", value);
+                return;
+            }
+        }
+        else if (type == 2)
+        {
+            //濡侲xAttr1鍊间负20103浠h〃褰撳墠宸茬粡杩囦簡绗�2绔犵1鍏崇3娉紱 value涓�201
+            if (PlayerDatas.Instance.baseData.ExAttr1 / 100 <= value)
+            {
+                SysNotifyMgr.Instance.ShowTip("HeroCountUnLock2", value / 100, value % 100);
+                return;
+            }
+        }
+        else if (type == 3)
+        {
+            if (TimeUtility.OpenDay < value - 1)
+            {
+                SysNotifyMgr.Instance.ShowTip("HeroCountUnLock3", value);
+                return;
+            }
+        }
+
+        //鍙互瑙i攣锛屼絾鏈В閿�
+        if (!IsUnLock(configIndex))
+        {
+            SysNotifyMgr.Instance.ShowTip("HeroCountUnLock4");
+        }
+    }
+
+
+    // 鍒锋柊鏈В閿佹灏嗕笂闄愮殑閰嶇疆绱㈠紩鍒楄〃
+    public void RefreshServerLockIndex()
+    {
+        lockIndexList.Clear();
+        for (int i = 0; i < lockHeroCountLimit.Length; i++)
+        {
+            if (!IsUnLock(i))
+            {
+                lockIndexList.Add(i);
+            }
+        }
+    }
+
+    public bool UnLockHeroCnt(int lockIndex)
+    {
+        if (lockIndex < 0 || lockIndex >= lockIndexList.Count)
+        {
+            return false;
+        }
+
+        return SetUnLock(lockIndexList[lockIndex]);
+
+    }
+
+    void OnQuickSettingUpdate()
+    {
+        RefreshServerLockIndex();
+    }
+    #endregion
+
 }
 

--
Gitblit v1.8.0