using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
class XMZZCampVicRewardWin : Window
|
{
|
[SerializeField] ChooseCell chooseCell;
|
[SerializeField] Transform getItemParent;
|
[SerializeField] Transform failParent;
|
[SerializeField] Button closeBtn;
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel
|
{
|
get
|
{
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
HeavenBattleModel _heavenModel;
|
HeavenBattleModel heavenModel
|
{
|
get { return _heavenModel ?? (_heavenModel = ModelCenter.Instance.GetModel<HeavenBattleModel>()); }
|
}
|
|
List<ChooseCell> GetList = new List<ChooseCell>();
|
|
|
protected override void BindController()
|
{
|
|
}
|
protected override void AddListeners()
|
{
|
|
}
|
|
protected override void OnPreOpen()
|
{
|
chooseCell.gameObject.SetActive(false);
|
closeBtn.AddListener(CloseWin);
|
CreateRewardCell();
|
}
|
protected override void OnAfterOpen()
|
{
|
this.transform.SetAsLastSibling();
|
}
|
|
protected override void OnPreClose()
|
{
|
closeBtn.RemoveAllListeners();
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
private void CreateRewardCell()
|
{
|
if (heavenModel.campVicRewardDict == null) return;
|
|
DestroyGetItemlist();
|
GetList.Clear();
|
foreach (int id in heavenModel.campVicRewardDict.Keys)
|
{
|
int itemId = id;
|
ChooseCell item = Instantiate(chooseCell);
|
item.transform.SetParent(getItemParent);
|
item.transform.localPosition = Vector3.zero;
|
item.transform.localScale = Vector3.one;
|
item.name = StringUtility.Contact("RewardCell", id);
|
item.gameObject.SetActive(true);
|
item.InitModel(heavenModel.campVicRewardDict[id], id);
|
GetList.Add(item);
|
item.cellBtn.RemoveAllListeners();
|
item.cellBtn.AddListener(() =>
|
{
|
ClickRewardCell(itemId);
|
});
|
}
|
|
foreach (int id in heavenModel.campFailRewardDict.Keys)
|
{
|
int itemId = id;
|
ChooseCell item = Instantiate(chooseCell);
|
item.transform.SetParent(failParent);
|
item.transform.localPosition = Vector3.zero;
|
item.transform.localScale = Vector3.one;
|
item.name = StringUtility.Contact("RewardCell", id);
|
item.gameObject.SetActive(true);
|
item.InitModel(heavenModel.campFailRewardDict[id], id);
|
GetList.Add(item);
|
item.cellBtn.RemoveAllListeners();
|
item.cellBtn.AddListener(() =>
|
{
|
ClickRewardCell(itemId);
|
});
|
}
|
}
|
|
private void DestroyGetItemlist()
|
{
|
for (int i = 0; i < GetList.Count; i++)
|
{
|
Destroy(GetList[i].gameObject);
|
}
|
}
|
private void ClickRewardCell(int itemId)
|
{
|
ItemAttrData attrData = new ItemAttrData(itemId);
|
itemTipsModel.SetItemTipsModel(attrData);
|
}
|
|
private void CloseWin()
|
{
|
CloseImmediately();
|
}
|
|
}
|
}
|