lcy
2025-12-30 520e953a380e6cb94d4789fac7f539bb7fb61878
Main/System/HeroFates/HeroFatesWin.cs
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@@ -5,7 +6,7 @@
public class HeroFatesWin : UIBase
{
    [SerializeField] ScrollerController scroller;
    [SerializeField] List<TextEx> attrs;
    [SerializeField] ScrollerController attrScroller;
    HeroFatesManager manager { get { return HeroFatesManager.Instance; } }
    protected override void InitComponent()
    {
@@ -15,6 +16,7 @@
    protected override void OnPreOpen()
    {
        scroller.OnRefreshCell += OnRefreshCell;
        attrScroller.OnRefreshCell += OnRefreshAttrCell;
        manager.OnUpdateHeroFatesInfoEvent += OnUpdateHeroFatesInfo;
        CreateScoller();
@@ -22,19 +24,26 @@
        manager.HasShowRedDotFates(out firstIndex);
        scroller.JumpIndex(firstIndex);
        DisplayAttrs();
        CreateAttrScoller();
    }
    protected override void OnPreClose()
    {
        scroller.OnRefreshCell -= OnRefreshCell;
        attrScroller.OnRefreshCell -= OnRefreshAttrCell;
        manager.OnUpdateHeroFatesInfoEvent -= OnUpdateHeroFatesInfo;
    }
    private void OnRefreshAttrCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell.GetComponent<HeroFatesAttrCell>();
        _cell?.Display(cell.index, totalAttrIdList, totalAttrDict);
    }
    private void OnUpdateHeroFatesInfo()
    {
        RefeshScoller();
        DisplayAttrs();
        CreateAttrScoller();
    }
    List<int> fatesIDList = new List<int>();
    private void OnRefreshCell(ScrollerDataType type, CellView cell)
@@ -62,29 +71,28 @@
        scroller.m_Scorller.RefreshActiveCellViews();
    }
    void DisplayAttrs()
    List<int> totalAttrIdList = new List<int>();
    Dictionary<int, long> totalAttrDict = new Dictionary<int, long>();
    void CreateAttrScoller()
    {
        Dictionary<int, long> totalAttrDict = manager.GetTotalAttr();
        if (attrs.IsNullOrEmpty() || totalAttrDict.IsNullOrEmpty())
        totalAttrDict = manager.GetTotalAttr();
        if (totalAttrDict.IsNullOrEmpty())
            return;
        List<int> totalAttrIdList = totalAttrDict.Keys
            .OrderByDescending(attrID => totalAttrDict[attrID] > 0)  // 属性值>0的排前面
            .ThenBy(attrID => attrID)  // 然后按attrID升序
            .ToList();
        for (int i = 0; i < attrs.Count; i++)
        totalAttrIdList = totalAttrDict.Keys
           .OrderByDescending(attrID => totalAttrDict[attrID] > 0)  // 属性值>0的排前面
           .ThenBy(attrID => attrID)  // 然后按attrID升序
           .ToList();
        attrScroller.Refresh();
        if (!totalAttrIdList.IsNullOrEmpty())
        {
            if (i < totalAttrDict.Count)
            int rowCount = Mathf.CeilToInt((float)totalAttrIdList.Count / manager.attrRowCountMax);
            for (int i = 0; i < rowCount; i++)
            {
                int attrID = totalAttrIdList[i];
                long attrValue = totalAttrDict[attrID];
                attrs[i].text = PlayerPropertyConfig.GetFullDescription(attrID, attrValue);
                attrs[i].SetActive(true);
            }
            else
            {
                attrs[i].SetActive(false);
                attrScroller.AddCell(ScrollerDataType.Header, i);
            }
        }
        attrScroller.Restart();
    }
}