using System;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class CrossSeverOneVsOneBuyMatchTimesWin : Window
|
{
|
[SerializeField] Text m_TodayBuyTimes;
|
[SerializeField] Text m_CostRemind;
|
[SerializeField] Button m_BuyTimes;
|
[SerializeField] Button m_Close;
|
[SerializeField] RectTransform m_ContainerBuylimit;
|
|
CrossServerOneVsOneModel crossServerModel { get { return ModelCenter.Instance.GetModel<CrossServerOneVsOneModel>(); } }
|
ulong price = 0;
|
#region Built-in
|
protected override void BindController()
|
{
|
|
}
|
protected override void AddListeners()
|
{
|
m_Close.AddListener(CloseClick);
|
m_BuyTimes.AddListener(ClickBuyTimes);
|
}
|
|
protected override void OnPreOpen()
|
{
|
CrossServerOneVsOnePlayerInfo.Instance.UpdatePlayerInfoEvent += SetDisplay;
|
SetDisplay();
|
}
|
protected override void OnAfterOpen()
|
{
|
|
}
|
|
protected override void OnPreClose()
|
{
|
CrossServerOneVsOnePlayerInfo.Instance.UpdatePlayerInfoEvent -= SetDisplay;
|
}
|
protected override void OnAfterClose()
|
{
|
|
}
|
#endregion
|
|
private void SetDisplay()
|
{
|
int remainBuyTimes = CrossServerOneVsOnePlayerInfo.Instance.GetDayRemainBuyNum();
|
price = (ulong)CrossServerOneVsOnePlayerInfo.Instance.GetBuyMatchNumPrice();
|
m_CostRemind.text = Language.Get("TimesBuyLanguage3", price);
|
m_ContainerBuylimit.SetActive(remainBuyTimes <= 0);
|
m_BuyTimes.SetActive(remainBuyTimes > 0);
|
if (remainBuyTimes > 0)
|
{
|
m_TodayBuyTimes.text = Language.Get("TimesBuyLanguage1", UIHelper.AppendColor(TextColType.Green, remainBuyTimes.ToString(), true), crossServerModel.buyMaxMatchNum);
|
}
|
else
|
{
|
m_TodayBuyTimes.text = Language.Get("TimesBuyLanguage1", UIHelper.AppendColor(TextColType.Red, remainBuyTimes.ToString(), true), crossServerModel.buyMaxMatchNum);
|
}
|
}
|
|
private void ClickBuyTimes()
|
{
|
if (!crossServerModel.TryGetBuyMatchTimes("CrossMatching21")) return;
|
|
ulong sumGold = UIHelper.GetMoneyCnt(1);
|
if (sumGold >= price)
|
{
|
SendBuyTimes();
|
}
|
else
|
{
|
WindowCenter.Instance.Open<RechargeTipWin>();
|
}
|
}
|
|
private void SendBuyTimes()
|
{
|
crossServerModel.SendBuyMatchCount();
|
}
|
}
|
}
|