using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
//竞技场主购买竞技次数
|
class ArenaAddTimesWin : ILWindow
|
{
|
Text m_InfoText;
|
ItemCell m_ItemCell;
|
Button m_UseBtn;
|
Transform m_TipGO;
|
int m_ItemID = 1507;
|
|
Text m_RemainCountText;
|
Button m_CloseBtn;
|
|
private PackModel m_PackModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
private bool IsWork = true;
|
|
|
protected override void BindController()
|
{
|
m_InfoText = proxy.GetWidgtEx<Text>("Txt_Info_1");
|
m_ItemCell = proxy.GetWidgtEx<ItemCell>("ItemCell");
|
m_UseBtn = proxy.GetWidgtEx<Button>("Btn_Use");
|
m_TipGO = proxy.GetWidgtEx<Transform>("Txt_Info_2");
|
m_RemainCountText = proxy.GetWidgtEx<Text>("Txt_RemainCount");
|
m_CloseBtn = proxy.GetWidgtEx<Button>("Btn_Close");
|
|
Init(false);
|
}
|
|
protected override void AddListeners()
|
{
|
m_CloseBtn.SetListener(() =>
|
{
|
WindowCenter.Instance.CloseIL<ArenaAddTimesWin>();
|
});
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
ArenaModel.Instance.playerInfo.UpdatePlayerInfoEvent -= RefreshUI;
|
m_PackModel.refreshItemCountEvent -= RefreshCell;
|
}
|
|
protected override void OnPreOpen()
|
{
|
ArenaModel.Instance.playerInfo.UpdatePlayerInfoEvent += RefreshUI;
|
m_PackModel.refreshItemCountEvent += RefreshCell;
|
RefreshUI();
|
RefreshCellUI();
|
}
|
private void RefreshCell(PackType type, int index, int id)
|
{
|
if (id == m_ItemID)
|
{
|
RefreshCellUI();
|
}
|
|
}
|
private void RefreshUI()
|
{
|
IsWork = true;
|
m_RemainCountText.text = StringUtility.Contact(Language.Get("FindPrecious_14"), ArenaModel.Instance.playerInfo.GetDayMatchInfo());
|
}
|
|
public void Init(bool bIsShowTip)
|
{
|
m_ItemID = 1507;
|
m_ItemCell.Init(new ItemCellModel(m_ItemID));
|
m_ItemCell.button.AddListener(() => ItemTipUtility.Show(m_ItemID));
|
m_TipGO.SetActive(bIsShowTip);
|
m_UseBtn.onClick.AddListener(OnUseBtnDown);
|
}
|
|
public void RefreshCellUI()
|
{
|
m_InfoText.text = ItemConfig.Get(m_ItemID).ItemName;
|
int itemCount = m_PackModel.GetItemCountByID(PackType.Item, m_ItemID);
|
string itemCountInfo = string.Format("{0}/{1}", UIHelper.AppendColor(itemCount > 0 ? TextColType.DarkGreen : TextColType.Red,
|
itemCount.ToString()), 1);
|
m_ItemCell.countText.gameObject.SetActive(true);
|
m_ItemCell.countText.text = itemCountInfo;
|
}
|
|
public void OnUseBtnDown()
|
{
|
if (!IsWork)
|
return;
|
int remainItemCount = m_PackModel.GetItemCountByID(PackType.Item, m_ItemID);
|
bool bIsItemUseOut = remainItemCount == 0;
|
|
int count = ArenaModel.Instance.playerInfo.GetDayMatchCount();
|
if (count >= ArenaModel.Instance.freeMaxMatchNum)
|
{
|
SysNotifyMgr.Instance.ShowTip("ArenaAddTimes");
|
return;
|
}
|
|
if (bIsItemUseOut)
|
{
|
//SysNotifyMgr.Instance.ShowTip("ArenaBuyTimes");
|
ItemTipUtility.Show(m_ItemID);
|
return;
|
}
|
ItemOperateUtility.Instance.UseItem(m_PackModel.GetItemGUIDByID(m_ItemID));
|
IsWork = false;
|
}
|
}
|