using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
class XMZZCampVicRewardWin : Window
|
{
|
[SerializeField] ChooseCell chooseCell;
|
[SerializeField] Transform getItemParent;
|
[SerializeField] Transform failParent;
|
[SerializeField] Button closeBtn;
|
|
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.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.SetActive(true);
|
item.InitModel(heavenModel.campVicRewardDict[id]);
|
GetList.Add(item);
|
item.button.RemoveAllListeners();
|
item.button.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.SetActive(true);
|
item.InitModel(heavenModel.campFailRewardDict[id]);
|
GetList.Add(item);
|
item.button.RemoveAllListeners();
|
item.button.AddListener(() =>
|
{
|
ClickRewardCell(itemId);
|
});
|
}
|
}
|
|
private void DestroyGetItemlist()
|
{
|
for (int i = 0; i < GetList.Count; i++)
|
{
|
Destroy(GetList[i].gameObject);
|
}
|
}
|
private void ClickRewardCell(int itemId)
|
{
|
ItemTipUtility.Show(itemId);
|
}
|
|
private void CloseWin()
|
{
|
CloseImmediately();
|
}
|
|
}
|
}
|