//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, June 13, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class NewDropItemWin : Window
|
{
|
[SerializeField] Text m_Description;
|
[SerializeField] Item[] m_ItemBehaviours;
|
[SerializeField] Button m_Close;
|
|
NewDropItemModel model { get { return ModelCenter.Instance.GetModel<NewDropItemModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.SetListener(() => { WindowCenter.Instance.Close<NewDropItemWin>(); });
|
}
|
|
protected override void OnPreOpen()
|
{
|
DisplayDescription();
|
DisplayItems();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
|
private void DisplayDescription()
|
{
|
var config = NewDropItemGroupConfig.Get(model.newDropGroupId);
|
m_Description.text = config.description;
|
}
|
|
private void DisplayItems()
|
{
|
var config = NewDropItemGroupConfig.Get(model.newDropGroupId);
|
for (var i = 0; i < m_ItemBehaviours.Length; i++)
|
{
|
var behaviour = m_ItemBehaviours[i];
|
if (i < config.items.Length)
|
{
|
behaviour.root.SetActive(true);
|
behaviour.Display(config.items[i].x, config.items[i].y);
|
}
|
else
|
{
|
behaviour.root.SetActive(false);
|
}
|
}
|
}
|
|
[System.Serializable]
|
public class Item
|
{
|
public Transform root;
|
public ItemBehaviour itemBehaviour;
|
public Text itemName;
|
|
public void Display(int id, int count)
|
{
|
itemBehaviour.SetItem(id, count);
|
var config = ItemConfig.Get(id);
|
itemName.text = config.ItemName;
|
}
|
|
}
|
|
}
|
|
}
|