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));
|
}
|
}
|