From e7e22b0cfafe53223b0a0f6b6189b2a8219f0740 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 09 九月 2025 17:08:34 +0800
Subject: [PATCH] 117 【武将】武将系统 - 图鉴

---
 Main/System/HeroUI/HeroCollectionWin.cs |  138 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+), 1 deletions(-)

diff --git a/Main/System/HeroUI/HeroCollectionWin.cs b/Main/System/HeroUI/HeroCollectionWin.cs
index 6624ec1..951de4e 100644
--- a/Main/System/HeroUI/HeroCollectionWin.cs
+++ b/Main/System/HeroUI/HeroCollectionWin.cs
@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.Linq;
 using UnityEngine;
 using UnityEngine.UI;
 
@@ -8,20 +9,155 @@
 /// </summary>
 public class HeroCollectionWin : UIBase
 {
+    [SerializeField] Button heroPackBtn;
+    [SerializeField] Text heroPackText;
+    [SerializeField] ScrollerController heroListScroller;
+    [SerializeField] List<Text> totalAttrList;
+    [SerializeField] Button attrBtn;
+    [SerializeField] HeroSelectBehaviour fiterManager;  //姝﹀皢绛涢��
 
+    SinglePack singlePack;
 
     protected override void InitComponent()
     {
+        attrBtn.AddListener(() =>
+        {
+            SmallTipWin.worldPos = CameraManager.uiCamera.ScreenToWorldPoint(Input.mousePosition);
+            SmallTipWin.showText = Language.Get("herocard6");
+            UIManager.Instance.OpenWindow<SmallTipWin>();
+        });
 
+        heroPackBtn.AddListener(() =>
+        {
+            HeroUIManager.Instance.QueryUnLockHeroPack();
+        });
     }
 
     protected override void OnPreOpen()
     {
-
+        singlePack = PackManager.Instance.GetSinglePack(PackType.Hero);
+        PackManager.Instance.gridRefreshEvent += GridRefreshEvent;
+        PackManager.Instance.RefreshItemEvent += RefreshItemEvent;
+        HeroUIManager.Instance.OnHeroCollectEvent += OnHeroCollectEvent;
+        heroListScroller.OnRefreshCell += OnRefreshCell;
+        HeroUIManager.Instance.selectHeroCollectListJob = 0;
+        HeroUIManager.Instance.selectHeroCollectListCountry = 0;
+        HeroUIManager.Instance.SortHeroCollectList();
+        Display();
     }
 
     protected override void OnPreClose()
     {
+
+        PackManager.Instance.gridRefreshEvent -= GridRefreshEvent;
+        PackManager.Instance.RefreshItemEvent -= RefreshItemEvent;
+        HeroUIManager.Instance.OnHeroCollectEvent -= OnHeroCollectEvent;
+        heroListScroller.OnRefreshCell -= OnRefreshCell;
+    }
+
+
+    void Display()
+    {
+        fiterManager.Display(0, HeroUIManager.Instance.selectHeroCollectListJob, HeroUIManager.Instance.selectHeroCollectListCountry, SelectJobCountry);
+        
+        CreateScroller();
+        RefreshTotalAttr();
+        RefreshPackCount();
+    }
+
+
+    void RefreshItemEvent(PackType type, int index, int itemID)
+    {
+        if (type != PackType.Hero)
+            return;
+
+
+        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();
+    }
+
+
+    void RefreshTotalAttr()
+    {
+        for (int i = 0; i < totalAttrList.Count; i++)
+        {
+            totalAttrList[i].text = PlayerPropertyConfig.GetFullDescription(PlayerPropertyConfig.basePerAttrs[i],
+            HeroUIManager.Instance.allHeroBookPer);
+        }
+    }
+
+
+    void SelectJobCountry(int job, int country)
+    {
+        HeroUIManager.Instance.selectHeroCollectListJob = job;
+        HeroUIManager.Instance.selectHeroCollectListCountry = country;
+        HeroUIManager.Instance.SortHeroCollectList();
+        CreateScroller();
+    }
+
+
+    void CreateScroller()
+    {
+        heroListScroller.Refresh();
+        var _List = HeroUIManager.Instance.heroCollectDict.Keys.ToList();
+        _List.Reverse();
+        for (int i = 0; i < _List.Count; i++)
+        {
+            var ids = HeroUIManager.Instance.heroCollectDict[_List[i]];
+            if (ids.Count == 0)
+                continue;
+            //鍝佽川
+            heroListScroller.AddCell(ScrollerDataType.Header, _List[i]);
+            //姝﹀皢
+            for (int j = 0; j < ids.Count; j++)
+            {
+                if (j % 4 == 0)
+                { 
+                    CellInfo cellInfo = new CellInfo();
+                    cellInfo.infoInt1 = _List[i];
+                    heroListScroller.AddCell(ScrollerDataType.Normal, j, cellInfo);
+                }
+            }
+        }
+        heroListScroller.Restart();
+    }
+
+
+    void OnRefreshCell(ScrollerDataType type, CellView cell)
+    {
+        if (type == ScrollerDataType.Header)
+        {
+            var _cell = cell.GetComponent<Image>();
+            _cell.SetSprite("herocoltitle" + cell.index);
+        }
+        else if (type == ScrollerDataType.Normal)
+        {
+            var _cell = cell as HeroCollectionLineCell;
+            _cell?.Display(cell.index, cell.info.Value.infoInt1);
+
+        }
+    }
+
+    void OnHeroCollectEvent()
+    {
+        RefreshTotalAttr();
+        heroListScroller.m_Scorller.RefreshActiveCellViews();
     }
 
 }
\ No newline at end of file

--
Gitblit v1.8.0