hch
6 天以前 47aa85c49c2f31f6ac728ea66defb1425bae85ba
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
 
//主界面卡牌
public class HeroFightingCardCell : MonoBehaviour
{
 
    [SerializeField] Button clickHeroBtn;
    [SerializeField] Image qualityBG;
    [SerializeField] Image heroIcon;
    [SerializeField] Text lvText;
    [SerializeField] Image countryImg;
    [SerializeField] Transform starRect;
    [SerializeField] List<Image> starsImg;
    [SerializeField] UIEffectPlayer fightEffect;
    [SerializeField] FillTween cdTween;
 
    [SerializeField] Button clickEmptyBtn;
 
 
    void OnEnable()
    {
        AutoFightModel.Instance.OnFightEvent += OnSkillCast;
    }
 
    void OnDisable()
    {
        AutoFightModel.Instance.OnFightEvent -= OnSkillCast;
    }
 
    string guid;
    public void Display(int index)
    {
        var team = TeamManager.Instance.GetTeam(TeamType.Story);
        var teamHero = team.GetServerHeroByIndex(index);
        guid = teamHero != null ? teamHero.guid : "";
        if (guid == "")
        {
            clickHeroBtn.SetActive(false);
            clickEmptyBtn.SetActive(true);
            clickEmptyBtn.AddListener(ClickEmpty);
            return;
        }
        else
        {
            clickHeroBtn.SetActive(true);
            clickEmptyBtn.SetActive(false);
        }
 
        var hero = HeroManager.Instance.GetHero(guid);
        var heroID = hero.heroId;
        var star = hero.heroStar;
        clickHeroBtn.AddListener(ClickHero);
        var heroConfig = HeroConfig.Get(heroID);
        qualityBG.SetSprite("herocBG" + heroConfig.Quality);
 
        var sprite = UILoader.LoadSprite("HeroHead", HeroSkinConfig.Get(hero.SkinID).RectangleIcon);
        if (sprite == null)
        {
            // 内网未配置时
            heroIcon.SetSprite("herohead_big_default");
        }
        else
        {
            heroIcon.overrideSprite = sprite;
        }
 
        if (star == 0)
        {
            starRect.SetActive(false);
        }
        else
        {
            starRect.SetActive(true);
            for (int i = 0; i < starsImg.Count; i++)
            {
                if ((star - 1) % starsImg.Count >= i)
                {
                    starsImg[i].SetActive(true);
                    starsImg[i].SetSprite("herostar" + (((star - 1) / starsImg.Count) + 1) * starsImg.Count);
                }
                else
                {
                    starsImg[i].SetActive(false);
                }
            }
        }
 
        countryImg.SetSprite(HeroUIManager.Instance.GetCountryIconName(heroConfig.Country));
        lvText.text = hero.heroLevel == 0 ? "" : Language.Get("L1094") + hero.heroLevel;
 
        RefreshFightIng(false);
 
    }
 
 
    void ClickHero()
    {
        HeroUIManager.Instance.selectHeroListJob = 0;
        HeroUIManager.Instance.selectHeroListCountry = 0;
        HeroUIManager.Instance.SortHeroList();
        HeroUIManager.Instance.selectHeroGuid = guid;
        UIManager.Instance.OpenWindow<HeroTrainWin>();
    }
 
    void ClickEmpty()
    {
        UIManager.Instance.OpenWindow<HeroCallWin>();
    }
    void OnSkillCast(bool isfighting)
    {
 
        if (isfighting && !string.IsNullOrEmpty(guid) && guid == AutoFightModel.Instance.heroGuid)
        {
            RefreshFightIng(true);
        }
 
    }
 
    void RefreshFightIng(bool isfighting)
    {
        if (isfighting)
        {
            fightEffect.Play();
            cdTween.SetStartState();
            cdTween.Play();
        }
        else
        {
            fightEffect.Stop();
            cdTween.Stop();
            cdTween.SetEndState();
        }
    }
 
}