From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/XPurchaseView.cs | 347 +++++++++++++++++++++ 1 file changed, 347 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XPurchaseView.cs (limited to 'Client/Assets/Scripts/XMainClient/XPurchaseView.cs') diff --git a/Client/Assets/Scripts/XMainClient/XPurchaseView.cs b/Client/Assets/Scripts/XMainClient/XPurchaseView.cs new file mode 100644 index 00000000..01b3ad83 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XPurchaseView.cs @@ -0,0 +1,347 @@ +using System; +using KKSG; +using UILib; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XPurchaseView : DlgBase + { + public override string fileName + { + get + { + return "Common/QuickPurchase"; + } + } + + public override int group + { + get + { + return 2; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + public override bool isHideTutorial + { + get + { + return true; + } + } + + private XPurchaseDocument _doc = null; + + private uint nextRecoverTimer = 0u; + + public static FatigueRecoverTime _fatigueTime = new FatigueRecoverTime(); + + public ItemEnum _showItem = ItemEnum.VIRTUAL_ITEM_MAX; + + protected override void Init() + { + this._doc = XDocuments.GetSpecificDocument(XPurchaseDocument.uuID); + this._doc.PurchaseView = this; + } + + public override void RegisterEvent() + { + base.uiBehaviour.m_QuickBuyDiamond.ID = 1UL; + base.uiBehaviour.m_QuickBuyDiamond.RegisterClickEventHandler(new ButtonClickEventHandler(this.DoPurchaseDiamond)); + base.uiBehaviour.m_QuickBuyDiamond10.ID = 10UL; + base.uiBehaviour.m_QuickBuyDiamond10.RegisterClickEventHandler(new ButtonClickEventHandler(this.DoPurchaseDiamond)); + base.uiBehaviour.m_QuickBuyDragonCoin.RegisterClickEventHandler(new ButtonClickEventHandler(this.DoPurchageDC)); + base.uiBehaviour.m_QuitBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + } + + protected override void OnUnload() + { + this._doc = null; + base.OnUnload(); + } + + public bool OnCloseClicked(IXUIButton sp) + { + bool flag = this.nextRecoverTimer > 0u; + if (flag) + { + XSingleton.singleton.KillTimer(this.nextRecoverTimer); + this.nextRecoverTimer = 0u; + } + this.SetVisibleWithAnimation(false, null); + return true; + } + + public void Refresh() + { + } + + public void ReceiveFatigueTime(PtcG2C_FatigueRecoverTimeNotify times) + { + XPurchaseView._fatigueTime.timeleft = times.Data.timeleft; + XPurchaseView._fatigueTime.fatigueid = times.Data.fatigueID; + XPurchaseView._fatigueTime.updatetime = DateTime.Now; + } + + public void ShowBorad(int itemid) + { + if (itemid != 1) + { + switch (itemid) + { + case 6: + case 7: + case 9: + this.ShowBorad((ItemEnum)itemid); + return; + case 11: + DlgBase.singleton.SetVisible(true, true); + return; + } + XSingleton.singleton.ShowItemAccess(itemid, null); + } + else + { + bool flag = XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; + if (flag) + { + DlgBase.singleton.Show(XSysDefine.XSys_Welfare_MoneyTree); + } + } + } + + public void ShowBorad(ItemEnum type) + { + if (type != ItemEnum.GOLD) + { + if (type != ItemEnum.DIAMOND) + { + this.SetVisibleWithAnimation(true, null); + this._showItem = type; + this.SetupPanel(); + this.RefreshBoard(); + bool flag = this._showItem == ItemEnum.FATIGUE; + if (flag) + { + bool flag2 = this.nextRecoverTimer > 0u; + if (flag2) + { + XSingleton.singleton.KillTimer(this.nextRecoverTimer); + } + this.nextRecoverTimer = XSingleton.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.UpdateTimer), null); + } + } + else + { + DlgBase.singleton.ShowPurchase(ItemEnum.DIAMOND); + } + } + else + { + DlgBase.singleton.Show(XSysDefine.XSys_Welfare_MoneyTree); + } + } + + public void RefreshBoard() + { + int level = (int)XSingleton.singleton.XPlayerData.Level; + XRechargeDocument specificDocument = XDocuments.GetSpecificDocument(XRechargeDocument.uuID); + int vipLevel = (int)specificDocument.VipLevel; + XPurchaseInfo purchaseInfo = this._doc.GetPurchaseInfo(level, vipLevel, this._showItem); + base.uiBehaviour.m_BuyNum.InputText = XLabelSymbolHelper.FormatCostWithIcon(purchaseInfo.GetCount, this._showItem); + bool flag = this._showItem == ItemEnum.DRAGON_COIN; + if (flag) + { + base.uiBehaviour.m_QuickBuyCost.InputText = XLabelSymbolHelper.FormatCostWithIcon(purchaseInfo.diamondCost, ItemEnum.DIAMOND); + } + else + { + base.uiBehaviour.m_QuickBuyCost.InputText = XLabelSymbolHelper.FormatCostWithIcon(purchaseInfo.dragoncoinCost, ItemEnum.DRAGON_COIN); + } + } + + protected void SetupPanel() + { + bool flag = this._showItem == ItemEnum.VIRTUAL_ITEM_MAX; + if (!flag) + { + base.uiBehaviour.m_Time.gameObject.SetActive(false); + base.uiBehaviour.m_BuyNumError.gameObject.SetActive(false); + ItemEnum showItem = this._showItem; + if (showItem != ItemEnum.GOLD) + { + if (showItem != ItemEnum.FATIGUE) + { + if (showItem == ItemEnum.DRAGON_COIN) + { + base.uiBehaviour.m_Title.SetText(XStringDefineProxy.GetString("PURCHASEDC")); + base.uiBehaviour.m_QuickBuyDiamond.gameObject.SetActive(true); + base.uiBehaviour.m_QuickBuyDiamond10.gameObject.SetActive(true); + base.uiBehaviour.m_QuickBuyDragonCoin.gameObject.SetActive(false); + base.uiBehaviour.m_Tips.SetText(XStringDefineProxy.GetString("Quick_Purchase_Tips2")); + } + } + else + { + base.uiBehaviour.m_Title.SetText(XStringDefineProxy.GetString("PURCHASEFAT")); + base.uiBehaviour.m_QuickBuyDiamond.gameObject.SetActive(false); + base.uiBehaviour.m_QuickBuyDiamond10.gameObject.SetActive(false); + base.uiBehaviour.m_QuickBuyDragonCoin.gameObject.SetActive(true); + base.uiBehaviour.m_Tips.SetText(XStringDefineProxy.GetString("Quick_Purchase_Tips3")); + } + } + else + { + base.uiBehaviour.m_Title.SetText(XStringDefineProxy.GetString("PURCHASEGOLD")); + base.uiBehaviour.m_QuickBuyDiamond.gameObject.SetActive(false); + base.uiBehaviour.m_QuickBuyDiamond10.gameObject.SetActive(false); + base.uiBehaviour.m_QuickBuyDragonCoin.gameObject.SetActive(true); + base.uiBehaviour.m_Tips.SetText(XStringDefineProxy.GetString("Quick_Purchase_Tips1")); + } + } + } + + public void ShowErrorCode(ErrorCode err) + { + bool flag = base.uiBehaviour != null && base.uiBehaviour.m_BuyNum != null; + if (flag) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString(err), "fece00"); + } + } + + public string FormatTime(uint time) + { + bool flag = time >= 3600u; + string result; + if (flag) + { + result = string.Format(string.Format("{0:D2}:{1:D2}:{2:D2}", (int)(time / 3600u), (int)(time % 3600u / 60u), time % 60u), new object[0]); + } + else + { + result = string.Format(string.Format("{0:D2}:{1:D2}", (int)(time % 3600u / 60u), time % 60u), new object[0]); + } + return result; + } + + public uint GetTimeLeft(ItemEnum itemid) + { + uint num = 0u; + for (int i = 0; i < XPurchaseView._fatigueTime.fatigueid.Count; i++) + { + bool flag = XPurchaseView._fatigueTime.fatigueid[i] == (uint)this._showItem; + if (flag) + { + num = XPurchaseView._fatigueTime.timeleft[i] / 1000u; + } + } + double totalSeconds = (DateTime.Now - XPurchaseView._fatigueTime.updatetime).TotalSeconds; + num -= (uint)totalSeconds; + return (num > 0u) ? num : 0u; + } + + public void UpdateTimer(object param) + { + uint num = 0u; + for (int i = 0; i < XPurchaseView._fatigueTime.fatigueid.Count; i++) + { + bool flag = XPurchaseView._fatigueTime.fatigueid[i] == (uint)this._showItem; + if (flag) + { + num = XPurchaseView._fatigueTime.timeleft[i]; + } + } + bool flag2 = num == 0u; + if (flag2) + { + base.uiBehaviour.m_Time.SetText(""); + } + else + { + double totalSeconds = (DateTime.Now - XPurchaseView._fatigueTime.updatetime).TotalSeconds; + num -= (uint)totalSeconds; + bool flag3 = num <= 0u; + if (flag3) + { + base.uiBehaviour.m_Time.SetText(""); + } + else + { + base.uiBehaviour.m_Time.SetText(""); + bool flag4 = this.nextRecoverTimer > 0u; + if (flag4) + { + XSingleton.singleton.KillTimer(this.nextRecoverTimer); + } + this.nextRecoverTimer = XSingleton.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.UpdateTimer), null); + } + } + } + + public bool DoPurchaseDiamond(IXUIButton sp) + { + this._doc.CommonQuickBuy(this._showItem, ItemEnum.DIAMOND, (uint)sp.ID); + return true; + } + + public bool DoPurchageDC(IXUIButton sp) + { + bool flag = this._showItem == ItemEnum.FATIGUE; + if (flag) + { + int level = (int)XSingleton.singleton.XPlayerData.Level; + XRechargeDocument specificDocument = XDocuments.GetSpecificDocument(XRechargeDocument.uuID); + int vipLevel = (int)specificDocument.VipLevel; + XPurchaseInfo purchaseInfo = this._doc.GetPurchaseInfo(level, vipLevel, ItemEnum.FATIGUE); + int num = (int)XBagDocument.BagDoc.GetVirtualItemCount(ItemEnum.FATIGUE); + bool flag2 = num + purchaseInfo.GetCount > int.Parse(XSingleton.singleton.GetValue("MaxFatigue")); + if (flag2) + { + XSingleton.singleton.ShowFatigueSureDlg(new ButtonClickEventHandler(this.GetFatigueSure)); + return true; + } + } + this._doc.CommonQuickBuy(this._showItem, ItemEnum.DRAGON_COIN, 1u); + return true; + } + + public bool GetFatigueSure(IXUIButton btn) + { + this._doc.CommonQuickBuy(this._showItem, ItemEnum.DRAGON_COIN, 1u); + DlgBase.singleton.SetVisible(false, true); + return true; + } + + public void ReqQuickCommonPurchase(ItemEnum itemEnum = ItemEnum.FATIGUE) + { + this.ReqQuickCommonPurchase(XFastEnumIntEqualityComparer.ToInt(itemEnum)); + } + + public void ReqQuickCommonPurchase(int itemid) + { + this.ShowBorad(itemid); + } + + public void UpdatePlayerBuyInfo(BuyGoldFatInfo buyInfo) + { + bool flag = this._doc == null; + if (!flag) + { + this._doc.InitPurchaseInfo(buyInfo); + this.RefreshBoard(); + } + } + } +} -- cgit v1.1-26-g67d0