using UnityEngine; 
 | 
using UnityEngine.UI; 
 | 
using System.Collections.Generic; 
 | 
  
 | 
public class HeroCollectionCardCell : MonoBehaviour 
 | 
{ 
 | 
    [SerializeField] Button heroCardBtn; 
 | 
    [SerializeField] Image heroCardBG; 
 | 
    [SerializeField] UIHeroController heroModel; 
 | 
    [SerializeField] List<Image> starImgList; 
 | 
    [SerializeField] Image countryImg; 
 | 
    [SerializeField] Image jobImg; 
 | 
    [SerializeField] Text nameText; 
 | 
    [SerializeField] Image trainStateImg; 
 | 
    [SerializeField] RedpointBehaviour redpoint; 
 | 
    [SerializeField] Button bookLVBtn; 
 | 
    [SerializeField] GameObject unGetObj; 
 | 
    [SerializeField] GameObject activeObj; // 可激活带流光效果材质 
 | 
  
 | 
    public void Display(int index, int quality) 
 | 
    { 
 | 
        var heroID = HeroUIManager.Instance.heroCollectDict[quality][index]; 
 | 
        var heroConfig = HeroConfig.Get(heroID); 
 | 
        HB122_tagSCHeroInfo.tagSCHero colData; 
 | 
        HeroUIManager.Instance.TryGetHeroBookInfo(heroID, out colData); 
 | 
        heroCardBG.SetSprite("herocardbg" + heroConfig.Quality); 
 | 
  
 | 
        //分为0未获得、1可激活、2常规、3突破升级、4、星升级、5已满级 
 | 
        int funcState = HeroUIManager.Instance.GetHeroBookState(heroID, quality); 
 | 
  
 | 
        activeObj.SetActive(funcState == 1); 
 | 
        bookLVBtn.SetActive(funcState > 1); 
 | 
        unGetObj.SetActive(funcState == 0); 
 | 
  
 | 
        countryImg.SetSprite(HeroUIManager.Instance.GetCountryIconName(heroConfig.Country)); 
 | 
        jobImg.SetSprite(HeroUIManager.Instance.GetJobIconName(heroConfig.Class)); 
 | 
        heroModel.Create(heroConfig.SkinIDList[0], heroConfig.UIScale); 
 | 
  
 | 
        redpoint.redpointId = MainRedDot.HeroCardCollectRedpoint * 10000000 + heroID; 
 | 
  
 | 
        if (funcState == 3 || funcState == 4) 
 | 
        { 
 | 
            trainStateImg.SetActive(true); 
 | 
            trainStateImg.SetSprite("herofuncstate4"); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            trainStateImg.SetActive(false); 
 | 
        } 
 | 
        nameText.text = colData.BookBreakLV == 0 ? heroConfig.Name : Language.Get("herocardbreaklv", heroConfig.Name, colData.BookBreakLV); 
 | 
  
 | 
        for (int i = 0; i < starImgList.Count; i++) 
 | 
        { 
 | 
            if (colData.BookStarLV == 0 && i == 0) 
 | 
            { 
 | 
                // 无星级 特殊处理 
 | 
                starImgList[i].SetActive(true); 
 | 
                starImgList[i].SetSprite("herostar" + colData.BookStarLV); 
 | 
            } 
 | 
            else if ((colData.BookStarLV - 1) % starImgList.Count >= i) 
 | 
            { 
 | 
                starImgList[i].SetActive(true); 
 | 
                starImgList[i].SetSprite("herostar" + (((colData.BookStarLV - 1) / starImgList.Count) + 1) * starImgList.Count); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                starImgList[i].SetActive(false); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        heroCardBtn.AddListener(() => 
 | 
        { 
 | 
            HeroUIManager.Instance.selectCollectHeroID = heroID; 
 | 
            var state = HeroUIManager.Instance.GetHeroBookState(heroID, quality); 
 | 
            if (state == 1 || state == 3 || state == 4) 
 | 
            { 
 | 
                UIManager.Instance.OpenWindow<HeroCollectionLvUpWin>(); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                HeroUIManager.Instance.selectForPreviewHeroID = heroID; 
 | 
                UIManager.Instance.OpenWindow<HeroBestWin>(); 
 | 
            } 
 | 
        }); 
 | 
         
 | 
        bookLVBtn.AddListener(() => 
 | 
        { 
 | 
            HeroUIManager.Instance.selectCollectHeroID = heroID; 
 | 
            UIManager.Instance.OpenWindow<HeroCollectionLvUpWin>(); 
 | 
        }); 
 | 
    } 
 | 
} 
 |