yyl
2025-10-31 39001a600fcae2bcf27c225df8752d75fb92fef4
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,34 @@
    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();
        }
    }
    #region 洗炼
    public string selectWashHeroGUID; //被洗练武将GUID
    public Action changeLockEvent;
    #endregion
    public List<string> heroEatList = new List<string>();
    void ParseGiftConfig()
    {
@@ -36,7 +64,13 @@
    //根据天赋锁状态获取消耗的材料数量
    public int GetTalentLockUseWashCount(HeroInfo hero)
    {
        return washByLockUseCounts[hero.GetTalentLockCount()];
        int heroTalentLockCount = hero.GetTalentLockCount();
        //不够取最后一个
        if (heroTalentLockCount >= washByLockUseCounts.Length)
        {
            heroTalentLockCount = washByLockUseCounts.Length - 1;
        }
        return washByLockUseCounts[heroTalentLockCount];
    }
@@ -53,7 +87,7 @@
    //星上限由品质 和 觉醒决定
    //星最终上限由品质 和 觉醒决定
    public int GetMaxStarCount(int heroID, int quality)
    {
        if (HeroAwakeConfig.GetHeroAwakeConfig(heroID, 1) == null)
@@ -70,9 +104,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,23 +124,114 @@
            {
                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, state, hero.heroId, i, hero.awakeLevel);
            }
            else
            {
                if (!beforeGiftIDList.IsNullOrEmpty())
                {
                    //对比情况下不显示
                    giftBaseCells[i].SetActive(false);
                    continue;
                }
                //非对比的显示
                if (i < normalGiftMaxCnt)
                {
                    giftBaseCells[i].Init(0, 0);
                }
                else
                {
                    int index = i;
                    giftBaseCells[i].Init(-1, 0, null, hero.heroId, index);
                    giftBaseCells[i].Init(-1, 0, 0, hero.heroId, i);
                }
            }
        }
    }
    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);
            }
        }
    }
    // public ushort ItemIndex;    //武将物品所在武将背包位置索引
    // public byte LockCnt;
    // public  byte[] LockTalentIndexs;    //锁定天赋索引列表
    // public byte OPType;    // 操作类型:0-执行洗炼;1-替换原天赋;2-保留原天赋
    public void SendWash(HeroInfo hero, byte opType)
    {
        var pack = new CB235_tagCSHeroWash();
        pack.ItemIndex = (ushort)hero.itemHero.gridIndex;
        pack.LockCnt = (byte)hero.talentLockList.Count;
        pack.LockTalentIndexs = new byte[pack.LockCnt];
        for (int i = 0; i < pack.LockCnt; i++)
        {
            pack.LockTalentIndexs[i] = (byte)hero.talentLockList[i];
        }
        pack.OPType = opType;
        GameNetSystem.Instance.SendInfo(pack);
    }
}