83 lines
2.1 KiB
C#
83 lines
2.1 KiB
C#
|
|
using CodeStage.AntiCheat.ObscuredTypes;
|
||
|
|
using PlayFab.ClientModels;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class ScrollViewMgr : BackKeyAdd
|
||
|
|
{
|
||
|
|
public UIScrollView m_scrollview;
|
||
|
|
public UIGrid m_grid;
|
||
|
|
public UITable m_table;
|
||
|
|
public GameObject go_card;
|
||
|
|
|
||
|
|
protected List<CardBase> list_CardBase = new List<CardBase>();
|
||
|
|
|
||
|
|
bool m_Repos = true;
|
||
|
|
|
||
|
|
protected void Reset_Grid()
|
||
|
|
{
|
||
|
|
if (m_grid) m_grid.repositionNow = true;
|
||
|
|
else if (m_table) m_table.repositionNow = true;
|
||
|
|
}
|
||
|
|
protected void Reset_Pos(bool _forcerepos = false)
|
||
|
|
{
|
||
|
|
if (m_Repos || _forcerepos)
|
||
|
|
{
|
||
|
|
m_Repos = false;
|
||
|
|
Reset_Grid();
|
||
|
|
if (m_scrollview != null) m_scrollview.ResetPosition();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<CardBase> Get_Cards() { return list_CardBase; }
|
||
|
|
|
||
|
|
protected void CardBase_AllOff()
|
||
|
|
{
|
||
|
|
for (int i = 0; i < list_CardBase.Count; i++)
|
||
|
|
list_CardBase[i].gameObject.SetActive(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
CardBase MakeCard(int i)
|
||
|
|
{
|
||
|
|
CardBase temp;
|
||
|
|
if (list_CardBase.Count > i) temp = list_CardBase[i];
|
||
|
|
else
|
||
|
|
{
|
||
|
|
temp = DSUtil.Get_Clone<CardBase>(go_card, m_grid ? m_grid.transform : m_table.transform);
|
||
|
|
list_CardBase.Add(temp);
|
||
|
|
}
|
||
|
|
|
||
|
|
return temp;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected virtual void Set_ScrollView<T>(List<T> _lst, bool _forcerepos = false)
|
||
|
|
{
|
||
|
|
CardBase_AllOff();
|
||
|
|
|
||
|
|
for (int i = 0; i < _lst.Count; i++)
|
||
|
|
MakeCard(i).Set(_lst[i]);
|
||
|
|
|
||
|
|
Reset_Pos(_forcerepos);
|
||
|
|
}
|
||
|
|
protected virtual void Set_ScrollView(List<TableDataBase> _lst, int _id, bool _forcerepos = false)
|
||
|
|
{
|
||
|
|
CardBase_AllOff();
|
||
|
|
|
||
|
|
for (int i = 0; i < _lst.Count; i++)
|
||
|
|
MakeCard(i).Set(_lst[i], _id);
|
||
|
|
|
||
|
|
Reset_Pos(_forcerepos);
|
||
|
|
}
|
||
|
|
protected virtual void Set_ScrollView_NotSet(int _makecount, bool _forcerepos = false)
|
||
|
|
{
|
||
|
|
CardBase_AllOff();
|
||
|
|
|
||
|
|
for (int i = 0; i < _makecount; i++)
|
||
|
|
{
|
||
|
|
if (list_CardBase.Count > i) { }
|
||
|
|
else list_CardBase.Add(DSUtil.Get_Clone<CardBase>(go_card, m_grid.transform));
|
||
|
|
}
|
||
|
|
|
||
|
|
Reset_Pos();
|
||
|
|
}
|
||
|
|
}
|