using System; using UnityEngine; using UnityEngine.UI; namespace Snxxz.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(); } } 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() { SetDisplay(); } protected override void OnAfterOpen() { } protected override void OnPreClose() { } 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.gameObject.SetActive(remainBuyTimes <= 0); m_BuyTimes.gameObject.SetActive(remainBuyTimes > 0); if(remainBuyTimes > 0) { m_TodayBuyTimes.text = Language.Get("TimesBuyLanguage1",UIHelper.AppendStringColor(TextColType.Green,remainBuyTimes.ToString()), crossServerModel.buyMaxMatchNum); } else { m_TodayBuyTimes.text = Language.Get("TimesBuyLanguage1", UIHelper.AppendStringColor(TextColType.Red, remainBuyTimes.ToString()), crossServerModel.buyMaxMatchNum); } } private void ClickBuyTimes() { ulong gold = UIHelper.GetMoneyCnt(1); ulong bindGold = UIHelper.GetMoneyCnt(2); ulong sumGold = gold + bindGold; if (sumGold >= price) { if (bindGold < price) { ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("FairyLand_Func13", PlayerDatas.Instance.baseData.GoldPaper, price, price - bindGold), (bool isOk) => { if (isOk) { SendBuyTimes(); } }); return; } else { SendBuyTimes(); } } else { WindowCenter.Instance.Open(); } } private void SendBuyTimes() { crossServerModel.SendBuyMatchCount(); CloseImmediately(); } } }