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/HeroListWin.cs |  135 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 110 insertions(+), 25 deletions(-)

diff --git a/Main/System/HeroUI/HeroListWin.cs b/Main/System/HeroUI/HeroListWin.cs
index 5f7eb94..7415bd7 100644
--- a/Main/System/HeroUI/HeroListWin.cs
+++ b/Main/System/HeroUI/HeroListWin.cs
@@ -16,33 +16,41 @@
     [SerializeField] GameObject attrOnTip;
     [SerializeField] Button attrOnTipBtn;
 
-    [SerializeField] GameObject foldObject;
-    [SerializeField] Button unFoldBtn; //灞曞紑鎸夐挳
-    [SerializeField] List<Button> countryBtnList;
-    [SerializeField] GameObject unFoldObject;
-    [SerializeField] Button foldBtn; //鏀惰捣鎸夐挳
-    [SerializeField] List<Button> jobBtnList;   //鍏ㄩ儴锛岃緭鍑恒�佽倝鐩俱�佽緟鍔┿�佹帶鍒�
     [SerializeField] Button changeHeroPosBtn; //甯冮樀鎸夐挳
+    [SerializeField] HeroSelectBehaviour fiterManager;  //姝﹀皢绛涢��
 
-
-    private List<Image> countrySelectImgList;
-    private List<Image> jobSelectImgList;
+    SinglePack singlePack;
 
     /// </summary>
     protected override void InitComponent()
     {
-        heroPackBtn.onClick.AddListener(() =>
+        heroPackBtn.AddListener(() =>
         {
             HeroUIManager.Instance.QueryUnLockHeroPack();
+        });
+        changeHeroPosBtn.AddListener(() =>
+        {
+            HeroUIManager.Instance.selectTeamType = TeamType.Story;
+            UIManager.Instance.OpenWindow<HeroPosWin>();
+        });
+        attrOnTipBtn.AddListener(() =>
+        {
+            attrOnTip.SetActive(!attrOnTip.activeSelf);
         });
     }
 
 
     protected override void OnPreOpen()
     {
+        HeroUIManager.Instance.selectHeroListJob = 0;
+        HeroUIManager.Instance.selectHeroListCountry = 0;
+        singlePack = PackManager.Instance.GetSinglePack(PackType.Hero);
         heroListScroller.OnRefreshCell += OnRefreshCell;
-        PackManager.Instance.RefreshItemEvent += RefreshPakCount;
-        HeroManager.Instance.SortHeroList();
+        PackManager.Instance.gridRefreshEvent += GridRefreshEvent;
+        PackManager.Instance.RefreshItemEvent += RefreshItemEvent;
+        UIManager.Instance.OnCloseWindow += OnCloseWindow;
+        HeroManager.Instance.onHeroDeleteEvent += HeroDeleteEvent;
+        HeroUIManager.Instance.SortHeroList();
         CreateScroller();
         Refresh();
     }
@@ -50,14 +58,50 @@
     protected override void OnPreClose()
     {
         heroListScroller.OnRefreshCell -= OnRefreshCell;
-        PackManager.Instance.RefreshItemEvent -= RefreshPakCount;
+        PackManager.Instance.RefreshItemEvent -= RefreshItemEvent;
+        PackManager.Instance.gridRefreshEvent -= GridRefreshEvent;
+        UIManager.Instance.OnCloseWindow -= OnCloseWindow;
+        HeroManager.Instance.onHeroDeleteEvent -= HeroDeleteEvent;
+    }
+
+
+    private void OnCloseWindow(UIBase closeUI)
+    {
+        //鍏朵粬姝﹀皢鍔熻兘浜х敓鏁版嵁鍙樺寲锛岄渶瑕佸埛鏂版灏嗗垪琛�
+        if (closeUI is HeroTrainWin ||
+            closeUI is HeroCallWin ||
+            closeUI is HeroPosWin)
+        {
+            HeroUIManager.Instance.SortHeroList();
+            CreateScroller();
+            Refresh();
+        }
     }
 
 
     public override void Refresh()
     {
-        SinglePack singlePack = PackManager.Instance.GetSinglePack(PackType.Item);
-        if (singlePack == null || singlePack.GetAllItems().Count <= 0)
+        RefreshEmptyTip();
+        OnBattleTeamAttrPer();
+
+        RefreshPackCount();
+
+        fiterManager.Display(0, HeroUIManager.Instance.selectHeroListJob, HeroUIManager.Instance.selectHeroListCountry, SelectJobCountry);
+
+    }
+
+    void HeroDeleteEvent(int heroID)
+    {
+        HeroUIManager.Instance.SortHeroList();
+        heroListScroller.m_Scorller.RefreshActiveCellViews();
+    }
+
+
+
+
+    void RefreshEmptyTip()
+    {
+        if (HeroUIManager.Instance.heroSortList.Count <= 0)
         {
             heroListEmpty.SetActive(true);
             heroListScroller.SetActive(false);
@@ -67,11 +111,40 @@
             heroListEmpty.SetActive(false);
             heroListScroller.SetActive(true);
         }
+    }
 
+    void SelectJobCountry(int job, int country)
+    {
+        HeroUIManager.Instance.selectHeroListJob = job;
+        HeroUIManager.Instance.selectHeroListCountry = country;
+        HeroUIManager.Instance.SortHeroList();
+        RefreshEmptyTip();
+        CreateScroller();
+    }
+
+    //涓婇樀鍔犳垚
+    void OnBattleTeamAttrPer()
+    {
+        var valuePer = 0;
+        var team = TeamManager.Instance.GetTeam(TeamType.Story);
+        if (team != null)
+        {
+            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)
+                {
+                    valuePer += hero.GetOnBattleAddPer();
+                }
+            }
+
+        }
         //涓婇樀灞炴��
         for (int i = 0; i < attrOnList.Count; i++)
         {
-            attrOnList[i].text = PlayerPropertyConfig.GetFullDescription(new Int2 (PlayerPropertyConfig.baseAttrs[i], 1 ));
+            attrOnList[i].text = PlayerPropertyConfig.GetFullDescription(new Int2(PlayerPropertyConfig.basePerAttrs[i], valuePer));
         }
     }
 
@@ -84,7 +157,7 @@
     void CreateScroller()
     {
         heroListScroller.Refresh();
-        for (int i = 0; i < HeroManager.Instance.heroSortList.Count; i++)
+        for (int i = 0; i < HeroUIManager.Instance.heroSortList.Count; i++)
         {
             if (i % 4 == 0)
             {
@@ -94,17 +167,29 @@
         heroListScroller.Restart();
     }
 
-    void RefreshPakCount(PackType type, int index, int itemID)
+    void RefreshItemEvent(PackType type, int index, int itemID)
     {
-        SinglePack singlePack = PackManager.Instance.GetSinglePack(PackType.Item);
-        if (singlePack == null)
+        if (type != PackType.Hero)
             return;
 
-        int count = singlePack.GetAllItems().Count;
 
-        heroPackText.text =  UIHelper.AppendColor(count > singlePack.unlockedGridCount ? TextColType.Red : TextColType.NavyBrown,
-                            string.Format("{0}/{1}", count, singlePack.unlockedGridCount));
-        
+        RefreshPackCount();
+
     }
-    
+
+    void RefreshPackCount()
+    {
+        int count = singlePack.GetAllItems().Count;
+        heroPackText.text = UIHelper.AppendColor(count >= singlePack.unlockedGridCount ? TextColType.Red : TextColType.NavyBrown,
+                            string.Format("{0}/{1}", count, singlePack.unlockedGridCount));
+
+    }
+
+    void GridRefreshEvent(PackType type)
+    { 
+        if (type != PackType.Hero)
+            return;
+
+        RefreshPackCount();
+    }
 }
\ No newline at end of file

--
Gitblit v1.8.0