66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using PlayFab.ClientModels;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ScrollViewArrMgr : BackKeyAdd
|
|
{
|
|
public UIScrollView[] m_scrollview;
|
|
public UIGrid[] m_grid;
|
|
public GameObject[] go_card;
|
|
|
|
protected Dictionary<int, List<CardBase>> dic_cardbase = new Dictionary<int, List<CardBase>>();
|
|
protected List<bool> m_Repos = new List<bool>();
|
|
|
|
protected void Reset_Grid(int _index) { m_grid[_index].repositionNow = true; }
|
|
protected void Reset_Pos(int _index, bool _forcerepos = false)
|
|
{
|
|
if (m_Repos[_index] || _forcerepos)
|
|
{
|
|
m_Repos[_index] = false;
|
|
Reset_Grid(_index);
|
|
if (m_scrollview != null && m_scrollview.Length > _index && m_scrollview[_index] != null)
|
|
m_scrollview[_index].ResetPosition();
|
|
}
|
|
}
|
|
|
|
protected void CardBase_AllOff(int _index)
|
|
{
|
|
if (m_Repos.Count == 0)
|
|
{
|
|
int large = m_scrollview != null ? m_scrollview.Length : 0;
|
|
large = large > m_grid.Length ? large : m_grid.Length;
|
|
for (int i = 0; i < large; i++)
|
|
{
|
|
m_Repos.Add(true);
|
|
dic_cardbase.Add(i, new List<CardBase>());
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < dic_cardbase[_index].Count; i++)
|
|
dic_cardbase[_index][i].gameObject.SetActive(false);
|
|
}
|
|
|
|
CardBase MakeCard(int _index, int i)
|
|
{
|
|
CardBase temp;
|
|
if (dic_cardbase[_index].Count > i) temp = dic_cardbase[_index][i];
|
|
else
|
|
{
|
|
temp = DSUtil.Get_Clone<CardBase>(go_card[_index], m_grid[_index].transform);
|
|
dic_cardbase[_index].Add(temp);
|
|
}
|
|
|
|
return temp;
|
|
}
|
|
|
|
protected virtual void Set_ScrollView<T>(int _index, List<T> _lst, bool _forcerepos = false)
|
|
{
|
|
CardBase_AllOff(_index);
|
|
|
|
for (int i = 0; i < _lst.Count; i++)
|
|
MakeCard(_index, i).Set(_lst[i]);
|
|
|
|
Reset_Pos(_index, _forcerepos);
|
|
}
|
|
} |