yyl
2025-12-08 4de42356ff71d295be7d3bf2e0b7d218b719ad9c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using UnityEngine;
 
public class LineupRecommendItem : MonoBehaviour
{
    [SerializeField] ButtonEx btnClick;
    [SerializeField] ImageEx imgSquareIcon;
    [SerializeField] ImageEx imgHeroHead;
    [SerializeField] ImageEx imgCountry;
    [SerializeField] TextEx txtName;
    [SerializeField] ImageEx imgMask;
    [SerializeField] TextEx txtNoHave;
    [SerializeField] ImageEx imgMoney;
    [SerializeField] TextEx txtMoney;
    [SerializeField] Color32 colMoneyNoActivate;
    [SerializeField] Color32 colMoneyCanActivate;
    [SerializeField] TextEx txtDesc;
    [SerializeField] ImageEx imgRed;
    LineupRecommendManager manager { get { return LineupRecommendManager.Instance; } }
    public void Display(int recommendID, int index)
    {
        if (!manager.TryGetHeroConfigByIndex(recommendID, index, out HeroConfig heroConfig))
            return;
 
        if (!manager.TryGetMoneyInfo(recommendID, index, out int moneyType, out int moneyNeedCnt))
            return;
 
        int heroID = heroConfig.HeroID;
        if (!manager.TryGetHeroSkinConfig(heroID, out HeroSkinConfig heroSkinConfig))
            return;
 
        var sprite = UILoader.LoadSprite("HeroHead", heroSkinConfig.SquareIcon);
        if (sprite == null)
        {
            imgHeroHead.SetSprite("herohead_default");
        }
        else
        {
            imgHeroHead.overrideSprite = sprite;
        }
 
        imgSquareIcon.SetSprite("heroheadBG" + heroConfig.Quality);
        imgCountry.SetSprite(HeroUIManager.Instance.GetCountryIconName(heroConfig.Country));
        txtName.text = heroConfig.Name;
        txtDesc.text = heroConfig.Desc;
 
        LineupRecommendHeroState heroState = manager.GetHeroState(recommendID, index);
        imgMask.SetActive(heroState != LineupRecommendHeroState.ActivateAndHave);
        txtNoHave.SetActive(heroState == LineupRecommendHeroState.ActivateButNoHave);
        imgMoney.SetActive(heroState == LineupRecommendHeroState.NoActivate || heroState == LineupRecommendHeroState.CanActivate);
        txtMoney.SetActive(heroState == LineupRecommendHeroState.NoActivate || heroState == LineupRecommendHeroState.CanActivate);
        imgRed.SetActive(heroState == LineupRecommendHeroState.CanActivate);
 
        imgMoney.SetIconWithMoneyType(moneyType);
        imgMoney.gray = heroState == LineupRecommendHeroState.NoActivate;
        txtMoney.text = moneyNeedCnt.ToString();
        txtMoney.color = heroState == LineupRecommendHeroState.NoActivate ? colMoneyNoActivate : colMoneyCanActivate;
 
        btnClick.SetListener(() =>
        {
            if (heroState == LineupRecommendHeroState.CanActivate)
            {
                manager.SendGetReward(recommendID, index);
            }
            else
            {
                HeroUIManager.Instance.selectForPreviewHeroID = heroConfig.HeroID;
                UIManager.Instance.OpenWindow<HeroBestWin>();
            }
        });
 
    }
 
 
}