using UnityEngine;
|
using UnityEngine.UI;
|
using System.Collections.Generic;
|
using System;
|
|
namespace Snxxz.UI
|
{
|
public class WishingPoolWin : Window
|
{
|
[SerializeField] DragItem dragItem;
|
[SerializeField] List<PoolItemCell> poolItemCells = new List<PoolItemCell>();
|
[SerializeField] List<WishingCell> wishingCells = new List<WishingCell>();
|
|
ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
|
WishingPoolModel wishingModel { get { return ModelCenter.Instance.GetModel<WishingPoolModel>(); } }
|
#region Built-in
|
protected override void BindController()
|
{
|
|
}
|
|
protected override void AddListeners()
|
{
|
|
}
|
|
protected override void OnPreOpen()
|
{
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
|
}
|
protected override void OnPreClose()
|
{
|
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
#endregion
|
|
private void Display()
|
{
|
UpdatePoolItem();
|
for(int i = 0; i < wishingCells.Count; i++)
|
{
|
UpdateWishItemByIndex(i);
|
}
|
}
|
|
|
protected override void LateUpdate()
|
{
|
if(wishingModel.isDraging)
|
{
|
|
}
|
}
|
|
private void UpdatePoolItem()
|
{
|
for (int i = 0; i < poolItemCells.Count; i++)
|
{
|
UpdatePoolItemByIndex(i);
|
}
|
}
|
|
private void UpdatePoolItemByIndex(int index)
|
{
|
int id = 0;
|
var poolItemCell = poolItemCells[index];
|
bool isPoolData = wishingModel.TryGetPoolDataByIndex(index, out id);
|
if (isPoolData)
|
{
|
poolItemCell.gameObject.SetActive(true);
|
poolItemCell.Display(id);
|
}
|
else
|
{
|
poolItemCell.gameObject.SetActive(false);
|
}
|
}
|
|
private void UpdateWishItemByIndex(int index)
|
{
|
int id = 0;
|
var wishCell = wishingCells[index];
|
bool isWishData = wishingModel.TryGetWishDataByIndex(index, out id);
|
if (isWishData)
|
{
|
wishCell.itemBaisc.gameObject.SetActive(true);
|
wishCell.noneItemObj.gameObject.SetActive(false);
|
ItemCellModel cellModel = new ItemCellModel(id);
|
wishCell.itemBaisc.Init(cellModel);
|
wishCell.itemBaisc.cellBtn.RemoveAllListeners();
|
wishCell.itemBaisc.cellBtn.AddListener(() =>
|
{
|
ItemAttrData attrData = new ItemAttrData(id);
|
tipsModel.SetItemTipsModel(attrData);
|
});
|
}
|
else
|
{
|
wishCell.itemBaisc.gameObject.SetActive(false);
|
wishCell.noneItemObj.gameObject.SetActive(true);
|
}
|
}
|
|
[Serializable]
|
public class WishingCell
|
{
|
public CommonItemBaisc itemBaisc;
|
public GameObject noneItemObj;
|
public Button noneItemBtn;
|
}
|
|
[Serializable]
|
public class DragItem
|
{
|
[SerializeField] CommonItemBaisc dragItemBasic;
|
[SerializeField] GameObject dragBestIcon;
|
}
|
}
|
}
|