hch
2025-09-05 277e13e374f7b647388e9df8e5540cca9e3b1128
Main/System/HeroUI/HeroUIManager.Talent.cs
@@ -4,6 +4,7 @@
using LitJson;
using UnityEngine;
using UnityEngine.UI;
//天赋
public partial class HeroUIManager : GameSystemManager<HeroUIManager>
@@ -17,7 +18,30 @@
    public int[] washByLockUseCounts;
    public int canWashStarLevel;   //达到X星可以洗练
    public string selectHeroGuidForGiftFunc;
    public string selectHeroGuidForGiftFunc;//武将主体GUID
    public int eatHeroIDForResult; //等待吞噬结果武将ID 为了弹成功界面使用
    public string selectHeroGuidForGiftFuncForSuccessWin;   //等待服务器返回的武将GUID 显示成功界面内容
    public List<int> heroBeforeGiftIDList = new List<int>();    //会有重复的ID,不要用字典
    public List<int> heroBeforeGiftLevelList = new List<int>();
    public event Action SelectEatHeroEvent;
    string m_SelectEatHeroGuid; //被吞噬武将GUID
    public string selectEatHeroGuid
    {
        get { return m_SelectEatHeroGuid; }
        set
        {
            m_SelectEatHeroGuid = value;
            SelectEatHeroEvent?.Invoke();
        }
    }
    public List<string> heroEatList = new List<string>();
    void ParseGiftConfig()
    {
@@ -70,9 +94,11 @@
        }
        return HeroQualityConfig.Get(quality).InitStarUpper + addStarCount;
    }
    public void RefreshGiftCell(GiftBaseCell[] giftBaseCells, HeroInfo hero)
    //beforeGiftIDList用于对比变化的天赋格子
    public void RefreshGiftCell(GiftBaseCell[] giftBaseCells, HeroInfo hero, List<int> beforeGiftIDList= null, List<int> beforeGiftLevelList= null)
    {
        int showCount = GetGiftGirdMaxCount(hero.heroId);
        for (int i = 0; i < giftBaseCells.Length; i++)
@@ -88,10 +114,42 @@
            {
                int giftID = hero.talentIDList[i];
                int giftLV = hero.talentLvList[i];
                giftBaseCells[i].Init(giftID, giftLV);
                int state = 0; //0:不显示 1:新增 2:提升
                if (!beforeGiftIDList.IsNullOrEmpty())
                {
                    if (i >= beforeGiftIDList.Count)
                    {
                        state = 1;
                    }
                    else
                    {
                        if (giftID != beforeGiftIDList[i])
                        {
                            state = 1;
                        }
                        else
                        {
                            if (giftLV > beforeGiftLevelList[i])
                            {
                                state = 2;
                            }
                        }
                    }
                }
                giftBaseCells[i].Init(giftID, giftLV, null, state);
            }
            else
            {
                if (!beforeGiftIDList.IsNullOrEmpty())
                {
                    //对比情况下不显示
                    giftBaseCells[i].SetActive(false);
                    continue;
                }
                //非对比的显示
                if (i < normalGiftMaxCnt)
                {
                    giftBaseCells[i].Init(0, 0);
@@ -106,5 +164,46 @@
        }
    }
    public void CacheHeroEatList()
    {
        heroEatList = PackManager.Instance.GetSinglePack(PackType.Hero).GetItemGUIDListById(
            HeroManager.Instance.GetHero(selectHeroGuidForGiftFunc).heroId);
        heroEatList.Remove(selectHeroGuidForGiftFunc);  //排除吞噬主体
        heroEatList.Sort(CmpDeleteHero);
    }
    public void ShowStarImg(int starCount, Image[] starImages, bool noStarShow = true)
    {
        int imgCount = starImages.Length;
        for (int i = 0; i < imgCount; i++)
        {
            if (starCount == 0 && i == 0)
            {
                if (noStarShow)
                {
                    // 无星级 特殊处理 显示一个空星星
                    starImages[i].SetActive(true);
                    starImages[i].SetSprite("herostar" + starCount);
                }
                else
                {
                    starImages[i].SetActive(false);
                }
            }
            else if ((starCount - 1) % imgCount >= i)
            {
                starImages[i].SetActive(true);
                starImages[i].SetSprite("herostar" + (((starCount - 1) / imgCount) + 1) * imgCount);
            }
            else
            {
                starImages[i].SetActive(false);
            }
        }
    }
}