lcy
1 天以前 2e7d66b9b7d541d878b2220fa1e50552e7553708
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
 
public class OtherHeroFightingCardItem : MonoBehaviour
{
    [SerializeField] Button btnClick;
    [SerializeField] Image imgQuality;
    [SerializeField] Image imgHero;
    [SerializeField] Text txtLv;
    [SerializeField] Image imgCountry;
    [SerializeField] Transform rectStar;
    [SerializeField] List<Image> imgStars;
    OtherPlayerDetailManager.RolePlusData.HeroData heroData;
    List<OtherPlayerDetailManager.RolePlusData.HeroData> heros;
    OtherPlayerDetailManager manager { get { return OtherPlayerDetailManager.Instance; } }
    public void Display(int index, List<OtherPlayerDetailManager.RolePlusData.HeroData> heros)
    {
        this.heros = heros;
        if (heros.IsNullOrEmpty() || index < 0 || index >= heros.Count)
        {
            return;
        }
        heroData = heros[index];
        var heroID = heroData.HeroID;
        if (!HeroConfig.HasKey(heroID))
        {
            return;
        }
 
        var heroConfig = HeroConfig.Get(heroID);
        imgQuality.SetSprite("herocBG" + heroConfig.Quality);
        imgCountry.SetSprite(HeroUIManager.Instance.GetCountryIconName(heroConfig.Country));
        txtLv.text = heroData.LV == 0 ? "" : Language.Get("L1094") + heroData.LV;
        DisplayHero(heroData);
        DisplayStars(heroData);
 
        btnClick.SetListener(ClickHero);
    }
 
    void DisplayHero(OtherPlayerDetailManager.RolePlusData.HeroData heroData)
    {
        var sprite = UILoader.LoadSprite("HeroHead", HeroSkinConfig.Get(heroData.SkinID).RectangleIcon);
        if (sprite == null)
        {
            // 内网未配置时
            imgHero.SetSprite("herohead_big_default");
        }
        else
        {
            imgHero.overrideSprite = sprite;
        }
    }
 
    void DisplayStars(OtherPlayerDetailManager.RolePlusData.HeroData heroData)
    {
        var star = heroData.Star;
        if (star == 0)
        {
            rectStar.SetActive(false);
        }
        else
        {
            rectStar.SetActive(true);
            for (int i = 0; i < imgStars.Count; i++)
            {
                if ((star - 1) % imgStars.Count >= i)
                {
                    imgStars[i].SetActive(true);
                    imgStars[i].SetSprite("herostar" + (((star - 1) / imgStars.Count) + 1) * imgStars.Count);
                }
                else
                {
                    imgStars[i].SetActive(false);
                }
            }
        }
    }
 
    void ClickHero()
    {
        if (heroData == null)
        {
            return;
        }
 
        OtherPlayerDetailManager.Instance.OpenOtherHeroDetailWin(new ViewHeroDetailData()
        {
            viewHeroType = 1,
            heroData = heroData,
            heroDatas = heros,
        });
    }
}