hch
昨天 f88d20f956b355588cf987a6534c39e016b1d8e8
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
using UnityEngine;
 
public class HeroDebutStarUpWin : UIBase
{
    [SerializeField] GradientText heroNameText;
    [SerializeField] TextEx timeText;
    [SerializeField] ImageEx heroImage;
    [SerializeField] ButtonEx goCallButton;
    [SerializeField] ButtonEx goInfoButton;
    [SerializeField] ButtonEx closeButton;
    [SerializeField] ScrollerController scroller;
    HeroDebutManager manager => HeroDebutManager.Instance;
    protected override void InitComponent()
    {
        closeButton.SetListener(CloseWindow);
        goCallButton.SetListener(() =>
        {
            UIManager.Instance.CloseWindow<HeroDebutStarUpWin>();
            UIManager.Instance.OpenWindow<HeroDebutCallWin>();
        });
        goInfoButton.SetListener(() =>
        {
            if (heroConfig == null) return;
            UIManager.Instance.CloseWindow<HeroDebutStarUpWin>();
            HeroUIManager.Instance.selectForPreviewHeroID = heroConfig.HeroID;
            UIManager.Instance.OpenWindow<HeroBestBaseWin>();
        });
    }
 
    protected override void OnPreOpen()
    {
        scroller.OnRefreshCell += OnRefreshCell;
        GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
        RechargeManager.Instance.rechargeCountEvent += OnRechargeCountEvent;
        manager.OnUpdateHeroAppearPlayerInfoEvent += OnUpdateHeroAppearPlayerInfoEvent;
        Display();
    }
 
    protected override void OnPreClose()
    {
        scroller.OnRefreshCell -= OnRefreshCell;
        GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
        RechargeManager.Instance.rechargeCountEvent -= OnRechargeCountEvent;
        manager.OnUpdateHeroAppearPlayerInfoEvent -= OnUpdateHeroAppearPlayerInfoEvent;
    }
 
    private void OnUpdateHeroAppearPlayerInfoEvent()
    {
        scroller.m_Scorller.RefreshActiveCellViews();
    }
 
    private void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell.GetComponent<HeroDebutStarUpCell>();
        _cell?.Display(cell.index, cell);
    }
 
    private void OnSecondEvent()
    {
        manager.GetActTimeStr(timeText);
    }
 
    private void OnRechargeCountEvent(int obj)
    {
        scroller.m_Scorller.RefreshActiveCellViews();
    }
 
    HeroConfig heroConfig;
    private void Display()
    {
        int heroID = manager.GetCurrentDisplayStarUpHeroId();
        heroConfig = HeroConfig.Get(heroID);
        if (heroConfig == null) return;
 
        var artConfig = ActHeroAppearArtConfig.Get(heroID);
        if (artConfig == null) return;
 
        var act = manager.GetOperationHeroAppearInfo();
        if (act == null) return;
 
        var config = ActHeroAppearConfig.Get(act.CfgID);
        if (config == null) return;
        
        heroNameText.text = heroConfig.Name;
        manager.SetGradientTextColor(heroNameText, artConfig.HeroNameColor);
        
        heroImage.SetSprite(StringUtility.Concat("HeroDebutStarUpHero_", heroID.ToString()));
        heroImage.SetNativeSize();
 
        CreateScroller(config, heroConfig);
    }
 
    private void CreateScroller(ActHeroAppearConfig appearConfig, HeroConfig heroConfig)
    {
 
 
        if (appearConfig == null || heroConfig == null) return;
        int starGiftTempID = appearConfig.StarGiftTempID;
        var list = ActHeroAppearStarConfig.GetHeroDebutAwardIndexSortList(starGiftTempID);
        if (list == null) return;
 
        scroller.Refresh();
        for (int i = 0; i < list.Count; i++)
        {
            var awardIndex = list[i];
 
            var config = ActHeroAppearStarConfig.GetConfig(starGiftTempID, awardIndex);
            if (config == null) continue;
 
            CellInfo cellInfo = new()
            {
                infoInt1 = heroConfig.HeroID,
                infoInt2 = i == 0 ? 1 : 0,
                infoInt3 = i == list.Count - 1 ? 1 : 0
            };
            scroller.AddCell(ScrollerDataType.Header, config.ID, cellInfo);
        }
        scroller.Restart();
        scroller.JumpIndex(manager.GetStarUpJumpIndex(starGiftTempID));
    }
}