using System;
|
using System.Collections.Generic;
|
using TableConfig;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class EquipSuitPreviewWin : Window
|
{
|
[SerializeField] PreviewCell previewCell;
|
[SerializeField] RectTransform cellParent;
|
[SerializeField] Button closeBtn;
|
[SerializeField] GameObject noSuitObj;
|
|
private List<PreviewCell> celllist = new List<PreviewCell>();
|
PlayerSuitModel _suitModel;
|
PlayerSuitModel SuitModel
|
{
|
get { return _suitModel ?? (_suitModel = ModelCenter.Instance.GetModel<PlayerSuitModel>()); }
|
}
|
|
protected override void BindController()
|
{
|
celllist.Clear();
|
CreatePreviewCell();
|
}
|
protected override void AddListeners()
|
{
|
|
}
|
protected override void OnPreOpen()
|
{
|
RefreshPreviewCell();
|
closeBtn.AddListener(CloseWin);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
|
}
|
|
protected override void OnPreClose()
|
{
|
closeBtn.RemoveAllListeners();
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
private void CreatePreviewCell()
|
{
|
Dictionary<string, EquipSuitAttrConfig> suitAttrDict = EquipSuitAttrConfig.GetSuitAttrDict();
|
foreach(var suitID in suitAttrDict.Keys)
|
{
|
PreviewCell cell = Instantiate(previewCell);
|
previewCell.gameObject.SetActive(false);
|
cell.transform.SetParent(cellParent);
|
cell.transform.localScale = Vector3.one;
|
cell.InitUI(suitID);
|
if(!celllist.Contains(cell))
|
{
|
celllist.Add(cell);
|
}
|
}
|
}
|
|
private void RefreshPreviewCell()
|
{
|
SuitModel.GetActivateSuitModel();
|
for(int i = 0; i < celllist.Count; i++)
|
{
|
celllist[i].RefreshUI(celllist[i].suitId);
|
}
|
|
if(SuitModel.activateAttrDict.Count > 0)
|
{
|
noSuitObj.SetActive(false);
|
}
|
else
|
{
|
noSuitObj.SetActive(true);
|
}
|
}
|
|
private void CloseWin()
|
{
|
CloseImmediately();
|
}
|
|
|
}
|
}
|