using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /// /// 武将吞噬界面 /// public class HeroGiftEatWin : UIBase { [SerializeField] HeroShowBaseCell heroShow; [SerializeField] GiftBaseCell[] giftCells; [SerializeField] Button addHeroBtn; [SerializeField] Button addHeroGo; [SerializeField] HeroShowBaseCell addHeroShow; [SerializeField] GiftBaseCell[] addGiftCells; [SerializeField] GameObject addTip; [SerializeField] GameObject addAttrGo; [SerializeField] Text[] addAttrTexts; [SerializeField] Text addGiftTip; [SerializeField] Button eatBtn; protected override void InitComponent() { addHeroBtn.AddListener(OpenSelectWin); addHeroGo.AddListener(OpenSelectWin); eatBtn.AddListener(EatHero); } protected override void OnPreOpen() { HeroUIManager.Instance.SelectEatHeroEvent += Display; Display(); } protected override void OnPreClose() { HeroUIManager.Instance.selectEatHeroGuid = ""; HeroUIManager.Instance.SelectEatHeroEvent -= Display; } 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(HeroUIManager.Instance.selectEatHeroGuid)) { addHeroBtn.SetActive(true); addHeroGo.SetActive(false); addTip.SetActive(true); addAttrGo.SetActive(false); } else { addHeroBtn.SetActive(false); addHeroGo.SetActive(true); addTip.SetActive(false); addAttrGo.SetActive(true); 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.basePerAttrs[i]; addAttrTexts[i].text = PlayerPropertyConfig.GetFullDescription(id, hero.qualityConfig.StarAddPer, "{0}+" + UIHelper.AppendColor(TextColType.Green, "{1}", true)); } addGiftTip.SetActive(!hero.IsFullGift()); } } void EatHero() { if (HeroUIManager.Instance.selectEatHeroGuid == "") { SysNotifyMgr.Instance.ShowTip("HeroGift3"); return; } var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuidForGiftFunc); //洗炼和觉醒的天赋未处理不可吞噬 if (hero.talentRandomIDList.Count > 0) { SysNotifyMgr.Instance.ShowTip("HeroGift4"); return; } if (hero.talentAwakeRandomIDList.Count > 0) { SysNotifyMgr.Instance.ShowTip("HeroGift5"); return; } var eatHero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectEatHeroGuid); if (hero == null || eatHero == null) return; if (hero.heroStar >= HeroUIManager.Instance.GetMaxStarCount(hero.heroId, hero.Quality)) { CloseWindow(); SysNotifyMgr.Instance.ShowTip("HeroGift7"); return; } if (hero.IsFullStar()) { CloseWindow(); SysNotifyMgr.Instance.ShowTip("HeroGift1"); 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(hero.talentIDList); HeroUIManager.Instance.heroBeforeGiftLevelList = new List(hero.talentLvList); HeroUIManager.Instance.lastFightPower = new KeyValuePair(hero.itemHero.guid, hero.CalculatePower(false)); //设置个等待回复的标识 显示成功界面 HeroUIManager.Instance.waitResponse = new WaitHeroFuncResponse() { guid = HeroUIManager.Instance.selectHeroGuidForGiftFuncForSuccessWin, type = HeroFuncType.Gift, time = Time.time }; } void OpenSelectWin() { var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuidForGiftFunc); if (hero == null) { CloseWindow(); return; } if (hero.heroStar >= HeroUIManager.Instance.GetMaxStarCount(hero.heroId, hero.Quality)) { CloseWindow(); SysNotifyMgr.Instance.ShowTip("HeroGift7"); return; } if (hero.IsFullStar()) { CloseWindow(); SysNotifyMgr.Instance.ShowTip("HeroGift1"); return; } UIManager.Instance.OpenWindow(); } }