hch
2025-09-05 277e13e374f7b647388e9df8e5540cca9e3b1128
Main/System/HeroUI/HeroGiftEatWin.cs
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -10,7 +11,7 @@
    [SerializeField] HeroShowBaseCell heroShow;
    [SerializeField] GiftBaseCell[] giftCells;
    [SerializeField] Button addHeroBtn;
    [SerializeField] GameObject addHeroGo;
    [SerializeField] Button addHeroGo;
    [SerializeField] HeroShowBaseCell addHeroShow;
    [SerializeField] GiftBaseCell[] addGiftCells;
    [SerializeField] GameObject addTip;
@@ -18,29 +19,46 @@
    [SerializeField] Text[] addAttrTexts;
    [SerializeField] Text addGiftTip;
    [SerializeField] GameObject eatBtn;
    [SerializeField] Button eatBtn;
    string addHeroGuid;
    protected override void InitComponent()
    {
        addHeroBtn.AddListener(() =>
        {
            UIManager.Instance.OpenWindow<HeroGiftRoleListWin>();
        });
        addHeroGo.AddListener(() =>
        {
            UIManager.Instance.OpenWindow<HeroGiftRoleListWin>();
        });
        eatBtn.AddListener(EatHero);
    }
    protected override void OnPreOpen()
    {
        var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuidForGiftFunc);
        Display(hero);
        HeroUIManager.Instance.SelectEatHeroEvent += Display;
        Display();
    }
    protected override void OnPreClose()
    {
        addHeroGuid = "";
        HeroUIManager.Instance.selectEatHeroGuid = "";
        HeroUIManager.Instance.SelectEatHeroEvent -= Display;
    }
    public void Display(HeroInfo hero)
    public void Display()
    {
        var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuidForGiftFunc);
        heroShow.Init(hero.heroId, hero.SkinID, hero.breakLevel, hero.heroStar, hero.awakeLevel, hero.heroLevel);
        HeroUIManager.Instance.RefreshGiftCell(giftCells, hero);
        if (string.IsNullOrEmpty(addHeroGuid))
        if (string.IsNullOrEmpty(HeroUIManager.Instance.selectEatHeroGuid))
        {
            addHeroBtn.SetActive(true);
            addHeroGo.SetActive(false);
@@ -53,16 +71,47 @@
            addHeroGo.SetActive(true);
            addTip.SetActive(false);
            addAttrGo.SetActive(true);
            var addHero = HeroManager.Instance.GetHero(addHeroGuid);
            var addHero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectEatHeroGuid);
            addHeroShow.Init(addHero.heroId, addHero.SkinID, addHero.breakLevel, addHero.heroStar, addHero.awakeLevel, addHero.heroLevel);
            HeroUIManager.Instance.RefreshGiftCell(addGiftCells, addHero);
            for (int i = 0; i < addAttrTexts.Length; i++)
            {
                int id = PlayerPropertyConfig.baseAttrs[i];
                addAttrTexts[i].text = PlayerPropertyConfig.GetFullDescription(id, hero.qualityConfig.StarAddPer);
                int id = PlayerPropertyConfig.basePerAttrs[i];
                addAttrTexts[i].text = PlayerPropertyConfig.GetFullDescription(id, hero.qualityConfig.StarAddPer,
                "{0}+" + UIHelper.AppendColor(TextColType.Green, "{1}", true));
            }
            addGiftTip.SetActive(hero.IsFullGift());
            addGiftTip.SetActive(!hero.IsFullGift());
        }
    }
    void EatHero()
    {
        if (HeroUIManager.Instance.selectEatHeroGuid == "")
        {
            SysNotifyMgr.Instance.ShowTip("HeroGift3");
            return;
        }
        var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuidForGiftFunc);
        var eatHero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectEatHeroGuid);
        if (hero == null || eatHero == null)
            return;
        var pack = new CB231_tagCSHeroStarUP();
        pack.ItemIndex = (ushort)hero.itemHero.gridIndex;
        pack.UseItemIndex = (ushort)eatHero.itemHero.gridIndex;
        GameNetSystem.Instance.SendInfo(pack);
        HeroUIManager.Instance.eatHeroIDForResult = hero.heroId;
        HeroUIManager.Instance.selectHeroGuidForGiftFuncForSuccessWin = HeroUIManager.Instance.selectHeroGuidForGiftFunc;
        HeroUIManager.Instance.heroBeforeGiftIDList = new List<int>(hero.talentIDList);
        HeroUIManager.Instance.heroBeforeGiftLevelList = new List<int>(hero.talentLvList);
        //设置个等待回复的标识 显示成功界面
        HeroUIManager.Instance.waitResponse = new WaitHeroFuncResponse()
        {
            guid = HeroUIManager.Instance.selectHeroGuidForGiftFuncForSuccessWin,
            type = HeroFuncType.Gift,
            time = Time.time
        };
    }
}