| | |
| | | using UnityEngine.UI; |
| | | using DG.Tweening; |
| | | using System.Linq; |
| | | using EnhancedUI.EnhancedScroller; |
| | | |
| | | public class HeroDebutCallWin : UIBase |
| | | { |
| | |
| | | [SerializeField] TextEx rankTipText; |
| | | [SerializeField] ButtonEx rateButton; |
| | | [SerializeField] ScrollerController scroller; |
| | | [SerializeField] ButtonEx historyButton; |
| | | [SerializeField] UIHeroController lhController; |
| | | [SerializeField] UIHeroController uiHeroController; |
| | | [SerializeField] HeroDebutCallBubbleCell[] bubbleCell; |
| | |
| | | changeHeroButton.SetListener(() => UIManager.Instance.OpenWindow<HeroDebutCallChangeWin>()); |
| | | rankButton.SetListener(() => UIManager.Instance.OpenWindow<HeroDebutRankWin>()); |
| | | rateButton.SetListener(() => UIManager.Instance.OpenWindow<HeroDebutCallRateWin>()); |
| | | historyButton.SetListener(() => UIManager.Instance.OpenWindow<HeroDebutCallHistoryWin>()); |
| | | previewButton.SetListener(OnClickPreview); |
| | | skipToggle.AddListener((value) => |
| | | { |
| | |
| | | PackManager.Instance.RefreshItemEvent += RefreshItemEvent; |
| | | scroller.OnRefreshCell += OnRefreshCell; |
| | | manager.OnUpdateGameRecInfo += OnUpdateGameRecInfo; |
| | | manager.OnUpdateHeroAppearPlayerInfoEvent += OnUpdateHeroAppearPlayerInfoEvent; |
| | | |
| | | if (manager.isSendFirst) |
| | | { |
| | |
| | | manager.OnUpdateGameRecInfo -= OnUpdateGameRecInfo; |
| | | manager.OnUpdateHeroAppearPlayerInfoEvent -= OnUpdateHeroAppearPlayerInfoEvent; |
| | | } |
| | | |
| | | |
| | | |
| | | // 1. 在类中声明一个全局的 Sequence 变量,用于统一管控动画 |
| | | private Sequence heroAnimSeq; |
| | |
| | | _cell.Display(cell.index, list); |
| | | } |
| | | |
| | | float autoScrollInterval = 2f; |
| | | private float autoScrollTimer = 0f; |
| | | private int currentScrollerIndex = 0; |
| | | private bool isScrollerReady = false; // 判定标志 |
| | | void CreateScroller() |
| | | { |
| | | list = manager.GetLastFourRecords(); |
| | | list = manager.GetGameRecList(); |
| | | scroller.Refresh(); |
| | | |
| | | int listCount = list?.Count ?? 0; |
| | | if (list != null) |
| | | { |
| | | for (int i = 0; i < list.Count; i++) |
| | | for (int i = 0; i < listCount; i++) |
| | | { |
| | | scroller.AddCell(ScrollerDataType.Header, i); |
| | | } |
| | | } |
| | | |
| | | |
| | | bool canScroll = listCount > 4;// 只有数量 > 4 时才开启 Loop 和计时器 |
| | | scroller.m_Scorller.Loop = canScroll; |
| | | isScrollerReady = canScroll; |
| | | |
| | | scroller.vertical = false; |
| | | scroller.horizontal = false; |
| | | scroller.Restart(); |
| | | |
| | | // 如果是循环模式,确保初始位置正确 |
| | | if (canScroll) |
| | | { |
| | | scroller.m_Scorller.JumpToDataIndex(0, |
| | | tweenType: EnhancedScroller.TweenType.immediate); |
| | | } |
| | | autoScrollTimer = 0f; |
| | | currentScrollerIndex = 0; |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | // 只有在数据就绪且超过 4 个时,才执行计时逻辑 |
| | | if (isScrollerReady) |
| | | { |
| | | autoScrollTimer += Time.deltaTime; |
| | | if (autoScrollTimer >= autoScrollInterval) |
| | | { |
| | | autoScrollTimer = 0f; |
| | | AutoScrollNext(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void AutoScrollNext() |
| | | { |
| | | if (list?.Count <= 4) |
| | | { |
| | | isScrollerReady = false; |
| | | return; |
| | | } |
| | | |
| | | currentScrollerIndex++; |
| | | // 在 Loop 模式下进行平滑跳转 |
| | | scroller.m_Scorller.JumpToDataIndex( |
| | | currentScrollerIndex % list.Count, |
| | | tweenType: EnhancedScroller.TweenType.easeInOutQuad, |
| | | tweenTime: 0.5f); |
| | | } |
| | | } |