yyl
2025-07-29 b0a5d4688f1af73b5ad03ccc2df11c9aac1523a9
Main/System/Hero/HeroManager.cs
@@ -10,8 +10,7 @@
    //初始创建(0725),后续跟随背包事件增加删除  key = guid
    protected Dictionary<string, HeroInfo> heroInfoDict = new Dictionary<string, HeroInfo>();
    //武将列表界面
    public List<string> heroSortList = new List<string>();
    //武将红点
    //MainRedDot.HeroCardRedpoint * 1000 + hero.itemHero.gridIndex;
@@ -41,7 +40,7 @@
    void OnBeforePlayerDataInitialize()
    {
        heroSortList.Clear();
        heroInfoDict.Clear();
    }
@@ -91,6 +90,11 @@
    {
        return heroInfoDict.Values.ToList();
    }
    public List<string> GetHeroGuidList()
    {
        return heroInfoDict.Keys.ToList();
    }
    public List<HeroInfo> GetPowerfulHeroList()
    {
@@ -119,52 +123,8 @@
        return retList;
    }
    public bool waitResortHeroList = false;
    //刷新时机, 打开武将界面 或者 关闭功能界面
    public void SortHeroList()
    {
        heroSortList = heroInfoDict.Keys.ToList();
        heroSortList.Sort(CmpHero);
    }
    int CmpHero(string guidA, string guidB)
    {
        HeroInfo heroA = heroInfoDict[guidA];
        HeroInfo heroB = heroInfoDict[guidB];
        if (heroA == null || heroB == null)
        {
            return 0;
        }
        // 排序规则:上阵>武将等级>突破等级>武将觉醒阶级>武将品质>武将吞噬星级>武将ID
        if (heroA.isInMainBattle != heroB.isInMainBattle)
        {
            return heroA.isInMainBattle ? -1 : 1;
        }
        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);
    }
}