//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, November 22, 2017
|
//--------------------------------------------------------
|
|
using Snxxz.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
|
public class ActivitySettleWin : Window
|
{
|
[SerializeField] List<ItemCell> activityItemCells = new List<ItemCell>();
|
[SerializeField] RectTransform container_ActivityReward;
|
[SerializeField] GameObject activityNullReawrd;
|
[SerializeField] List<ItemCell> achieveItemCells = new List<ItemCell>();
|
[SerializeField] RectTransform container_AchieveReward;
|
[SerializeField] GameObject achieveNullReawrd;
|
[SerializeField] Button rewardGetBtn;
|
|
DungeonModel m_DungeonModel;
|
DungeonModel dungeonModel
|
{
|
get
|
{
|
return m_DungeonModel ?? (m_DungeonModel = ModelCenter.Instance.GetModel<DungeonModel>());
|
}
|
}
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
rewardGetBtn.onClick.AddListener(CloseClick);
|
}
|
|
protected override void OnPreOpen()
|
{
|
ShowActivityReward();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
dungeonModel.dungeonResult = default(DungeonResult);
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
void ShowActivityReward()
|
{
|
foreach (var item in achieveItemCells)
|
{
|
item.gameObject.SetActive(false);
|
}
|
foreach (var item in activityItemCells)
|
{
|
item.gameObject.SetActive(false);
|
}
|
var actiivityItems = dungeonModel.dungeonResult.itemInfo;
|
bool hasReward = actiivityItems != null && actiivityItems.Length > 0;
|
container_ActivityReward.gameObject.SetActive(hasReward);
|
activityNullReawrd.SetActive(!hasReward);
|
if (hasReward)
|
{
|
for (int i = 0; i < actiivityItems.Length; i++)
|
{
|
if (i < activityItemCells.Count)
|
{
|
activityItemCells[i].gameObject.SetActive(true);
|
ItemCell itemCell = activityItemCells[i];
|
ServerItem serverItem = actiivityItems[i];
|
ItemCellModel cellModel = new ItemCellModel(serverItem.ItemID, false, (ulong)serverItem.Count
|
, "", PackType.Deleted, false, ConfigParse.Analysis(serverItem.UserData));
|
itemCell.Init(cellModel);
|
itemCell.button.RemoveAllListeners();
|
itemCell.button.AddListener(() =>
|
{
|
ShowItemDetails(serverItem);
|
});
|
}
|
}
|
}
|
|
var achieveItems = dungeonModel.dungeonResult.succItemInfo;
|
hasReward = achieveItems != null && achieveItems.Length > 0;
|
container_AchieveReward.gameObject.SetActive(hasReward);
|
achieveNullReawrd.SetActive(!hasReward);
|
if (hasReward)
|
{
|
for (int i = 0; i < achieveItems.Length; i++)
|
{
|
if (i < achieveItemCells.Count)
|
{
|
achieveItemCells[i].gameObject.SetActive(true);
|
ItemCell itemCell = achieveItemCells[i];
|
ServerItem serverItem = achieveItems[i];
|
ItemCellModel cellModel = new ItemCellModel(serverItem.ItemID, false, (ulong)serverItem.Count,
|
"", PackType.Deleted, false, ConfigParse.Analysis(serverItem.UserData));
|
itemCell.Init(cellModel);
|
itemCell.button.RemoveAllListeners();
|
itemCell.button.AddListener(() =>
|
{
|
ShowItemDetails(serverItem);
|
});
|
}
|
}
|
}
|
}
|
|
private void ShowItemDetails(ServerItem serverItem)
|
{
|
ItemTipUtility.Show(serverItem.ItemID);
|
}
|
}
|
|
}
|
|
|
|
|