| | |
| | | private List<HA525_tagSCFamilyAtkDefBatInfo.tagSCFamilyAtkDefBatMem> m_SortedDefenders; |
| | | private List<HA525_tagSCFamilyAtkDefBatInfo.tagSCFamilyAtkDefBatMem> m_RemainingDefenders; |
| | | private bool m_DeferBattleScrollerRefresh; |
| | | private static bool s_HasPendingScrollPosition; |
| | | private static float s_PendingScrollPosition; |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | |
| | | { |
| | | OnDayRefresh(); |
| | | Display(); |
| | | RefreshBattleScroller(); |
| | | RefreshBattleScroller(true); |
| | | } |
| | | |
| | | private void OnDayRefresh() |
| | |
| | | RefreshBattleScroller(); |
| | | } |
| | | |
| | | public void SaveScrollPositionForNextOpen() |
| | | { |
| | | if (scroller == null || scroller.m_Scorller == null) |
| | | return; |
| | | |
| | | s_PendingScrollPosition = scroller.m_Scorller.ScrollPosition; |
| | | s_HasPendingScrollPosition = true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新战场Scroller数据 |
| | | /// </summary> |
| | | private void RefreshBattleScroller() |
| | | private void RefreshBattleScroller(bool keepScrollPosition = false) |
| | | { |
| | | int oldCellCount = scroller.GetNumberOfCells(scroller.m_Scorller); |
| | | int newCellCount = RefreshBattleScrollerData(); |
| | | |
| | | if (keepScrollPosition && oldCellCount == newCellCount) |
| | | { |
| | | scroller.m_Scorller.RefreshActiveCellViews(); |
| | | return; |
| | | } |
| | | |
| | | // 重新构建Scroller |
| | | scroller.Refresh(); |
| | | |
| | | // 添加HeaderCell(第一条) |
| | | scroller.AddCell(ScrollerDataType.Header, 0); |
| | | |
| | | // 剩余成员每2个一组添加NormalCell |
| | | int normalCellCount = newCellCount - 1; |
| | | for (int i = 0; i < normalCellCount; i++) |
| | | { |
| | | scroller.AddCell(ScrollerDataType.Normal, i + 1); |
| | | } |
| | | |
| | | scroller.Restart(); |
| | | TryRestorePendingScrollPosition(); |
| | | } |
| | | |
| | | private void TryRestorePendingScrollPosition() |
| | | { |
| | | if (!s_HasPendingScrollPosition || scroller == null || scroller.m_Scorller == null) |
| | | return; |
| | | |
| | | scroller.m_Scorller.ScrollPosition = s_PendingScrollPosition; |
| | | s_HasPendingScrollPosition = false; |
| | | } |
| | | |
| | | private int RefreshBattleScrollerData() |
| | | { |
| | | // 根据当前Tab设置己方/敌方 |
| | | switch (functionOrder) |
| | |
| | | m_RemainingDefenders.Add(m_SortedDefenders[i]); |
| | | } |
| | | |
| | | // 重新构建Scroller |
| | | scroller.Refresh(); |
| | | |
| | | // 添加HeaderCell(第一条) |
| | | scroller.AddCell(ScrollerDataType.Header, 0); |
| | | |
| | | // 剩余成员每2个一组添加NormalCell |
| | | int remainingCount = m_RemainingDefenders.Count; |
| | | int normalCellCount = Mathf.CeilToInt((float)remainingCount / 2); |
| | | for (int i = 0; i < normalCellCount; i++) |
| | | { |
| | | scroller.AddCell(ScrollerDataType.Normal, i + 1); |
| | | } |
| | | |
| | | scroller.Restart(); |
| | | int normalCellCount = Mathf.CeilToInt((float)m_RemainingDefenders.Count / 2); |
| | | return normalCellCount + 1; |
| | | } |
| | | |
| | | /// <summary> |