//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, May 10, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI {
|
|
public class RechargeBoxWin : Window
|
{
|
[SerializeField] RareItem[] m_Items;
|
[SerializeField] Text m_Cost;
|
[SerializeField] Button m_CloseBtn;
|
[SerializeField] Button m_RechargeBtn;
|
TextEx orgPrice;
|
|
|
VipModel m_Model;
|
VipModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<VipModel>());
|
}
|
}
|
#region Built-in
|
protected override void BindController()
|
{
|
var obj = m_RechargeBtn.FindComponent("Text", "Txt_orgPrice");
|
if (obj != null)
|
orgPrice = obj as TextEx;
|
}
|
|
protected override void AddListeners()
|
{
|
m_CloseBtn.onClick.AddListener(CloseClick);
|
m_RechargeBtn.onClick.AddListener(OnRecharge);
|
for (int i = 0; i < m_Items.Length; i++)
|
{
|
var _index = i;
|
m_Items[i].button.onClick.AddListener(() =>
|
{
|
OnItemClick(_index);
|
});
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
Display();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
void Display()
|
{
|
var _config = CTGConfig.Get(model.presentSelectRechargeId);
|
if (_config == null)
|
{
|
return;
|
}
|
m_Cost.text = Language.Get("RechargeBoxWin1", UIHelper.GetMoneyFormat((int)model.GetPayRmb(_config.RecordID)));
|
|
if (orgPrice != null)
|
{
|
orgPrice.SetActiveIL(PlayerDatas.Instance.baseData.IsActive90Off);
|
orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat((int)model.GetOrgPayRmb(_config.RecordID)));
|
}
|
|
var _list = model.m_RechargeGainItemDict[model.presentSelectRechargeId];
|
for (int i = 0; i < m_Items.Length; i++)
|
{
|
if (i >= _list.Count)
|
{
|
m_Items[i].SetActive(false);
|
continue;
|
}
|
m_Items[i].SetActive(true);
|
var _item = _list[i];
|
var _itemModel = new ItemCellModel(_item.id, false, (ulong)_item.count);
|
m_Items[i].SetItemRare(_itemModel, 4);
|
}
|
}
|
|
private void OnRecharge()
|
{
|
model.CTG(model.presentSelectRechargeId);
|
}
|
|
private void OnItemClick(int index)
|
{
|
var _list = model.m_RechargeGainItemDict[model.presentSelectRechargeId];
|
if (index < _list.Count)
|
{
|
var item = _list[index];
|
ItemTipUtility.Show(item.id);
|
}
|
}
|
}
|
|
}
|
|
|
|
|