using System.Collections.Generic; 
 | 
using UnityEngine; 
 | 
using UnityEngine.UI; 
 | 
  
 | 
  
 | 
/// <summary> 
 | 
/// 武将洗炼当前的天赋 
 | 
/// </summary> 
 | 
public class HeroGiftWashCell : MonoBehaviour 
 | 
{ 
 | 
    [SerializeField] GiftBaseCell giftCell; 
 | 
    [SerializeField] Button lockBtn; 
 | 
    [SerializeField] Image lockImg; 
 | 
  
 | 
    [SerializeField] UIEffectPlayer effectPlayer; 
 | 
  
 | 
  
 | 
    public void Display(HeroInfo hero, int index) 
 | 
    { 
 | 
        int giftID = hero.talentIDList[index]; 
 | 
        int giftLV = hero.talentLvList[index]; 
 | 
  
 | 
        giftCell.Init(giftID, giftLV, 0, hero.heroId, index, hero.awakeLevel); 
 | 
  
 | 
        if (hero.talentLockList.IndexOf(index) != -1) 
 | 
        { 
 | 
            lockImg.SetSprite("lockImage"); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            lockImg.SetSprite("unlockImage"); 
 | 
        } 
 | 
  
 | 
        lockBtn.AddListener(() => 
 | 
        { 
 | 
            var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectWashHeroGUID); 
 | 
            if (hero == null) 
 | 
            { 
 | 
                return; 
 | 
            } 
 | 
  
 | 
            //没有发锁定包,客户端自己保存 
 | 
            var state = hero.talentLockList.IndexOf(index) == -1 ? 0 : 1; 
 | 
  
 | 
            if (state == 0 && hero.GetTalentLockCount() >= hero.talentIDList.Count - 1) 
 | 
            { 
 | 
                //至少要保留一个天赋未锁定 
 | 
                SysNotifyMgr.Instance.ShowTip("HeroGift6"); 
 | 
                return; 
 | 
            } 
 | 
  
 | 
            hero.SetTalentLockState(index, state == 1 ? 0 : 1); 
 | 
  
 | 
            if (hero.talentLockList.IndexOf(index) != -1) 
 | 
            { 
 | 
                lockImg.SetSprite("lockImage"); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                lockImg.SetSprite("unlockImage"); 
 | 
            } 
 | 
             
 | 
            HeroUIManager.Instance.changeLockEvent?.Invoke(); 
 | 
        }); 
 | 
  
 | 
    } 
 | 
  
 | 
    public void ShowEffect(HeroInfo hero, int index) 
 | 
    { 
 | 
        if (hero.talentLockList.IndexOf(index) != -1) 
 | 
        { 
 | 
            return; 
 | 
        } 
 | 
         
 | 
        effectPlayer.Play(true, true); 
 | 
    } 
 | 
  
 | 
} 
 |