From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/GamePayDiaMallHander.cs | 543 +++++++++++++++++++++ 1 file changed, 543 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/GamePayDiaMallHander.cs (limited to 'Client/Assets/Scripts/XMainClient/GamePayDiaMallHander.cs') diff --git a/Client/Assets/Scripts/XMainClient/GamePayDiaMallHander.cs b/Client/Assets/Scripts/XMainClient/GamePayDiaMallHander.cs new file mode 100644 index 00000000..e906e969 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/GamePayDiaMallHander.cs @@ -0,0 +1,543 @@ +using System; +using System.Collections.Generic; +using KKSG; +using MiniJSON; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class GamePayDiaMallHander : DlgHandlerBase + { + public uint VipLevel + { + get + { + return 0u; + } + } + + public GameObject VIPFrame; + + public GameObject RechargeFrame; + + public IXUILabel m_NextVipTip; + + public IXUILabel m_CurrVipLevel; + + public IXUILabel m_NextVipLevel; + + public Transform m_NextVip; + + public IXUILabel m_VipProgressValue; + + public IXUIProgress m_VipProgress; + + public IXUIButton m_SwitchBtn; + + public IXUILabel m_SwitchLabel; + + public GameObject m_SwitchRedPoint; + + public IXUIList m_RechargeItemList; + + public IXUIScrollView m_RechargeScrollView; + + public XUIPool m_RechargeDiamondPool = new XUIPool(XSingleton.singleton.m_uiTool); + + public IXUIButton _CustomerService; + + public IXUIButton _wifiBtn; + + public XUIPool m_TabTool = new XUIPool(XSingleton.singleton.m_uiTool); + + public IXUIScrollView m_TabScrollView; + + public XUIPool m_DescPool = new XUIPool(XSingleton.singleton.m_uiTool); + + public XUIPool m_ItemPool = new XUIPool(XSingleton.singleton.m_uiTool); + + public IXUISprite m_GetBtn; + + public IXUILabel m_GetBtnLabel; + + public GameObject m_GetBtnRedPoint; + + public IXUILabel m_ViewLevel; + + private List m_EffectCache = new List(); + + private XRechargeDocument _Doc; + + public int CurrentClick = 0; + + private List _redPointList = new List(); + + protected override void Init() + { + this._Doc = XDocuments.GetSpecificDocument(XRechargeDocument.uuID); + this._Doc.RechargeView = this; + this.m_NextVipTip = (base.transform.Find("Bg/UpView/Tip").GetComponent("XUILabel") as IXUILabel); + this.m_CurrVipLevel = (base.transform.Find("Bg/UpView/vipicon1/Level1").GetComponent("XUILabel") as IXUILabel); + this.m_NextVipLevel = (base.transform.Find("Bg/UpView/vipicon2/Level2").GetComponent("XUILabel") as IXUILabel); + this.m_NextVip = base.transform.Find("Bg/UpView/vipicon2"); + this.m_VipProgressValue = (base.transform.Find("Bg/UpView/Progress").GetComponent("XUILabel") as IXUILabel); + this.m_VipProgress = (base.transform.Find("Bg/UpView/ProgressBar").GetComponent("XUIProgress") as IXUIProgress); + this.m_SwitchBtn = (base.transform.Find("Bg/UpView/SwitchBtn").GetComponent("XUIButton") as IXUIButton); + this.m_SwitchLabel = (base.transform.Find("Bg/UpView/SwitchBtn/Label").GetComponent("XUILabel") as IXUILabel); + this.m_SwitchRedPoint = this.m_SwitchBtn.gameObject.transform.Find("RedPoint").gameObject; + this.m_RechargeScrollView = (base.transform.Find("Bg/RechargeFrame/Scroll View").GetComponent("XUIScrollView") as IXUIScrollView); + this.m_RechargeItemList = (base.transform.Find("Bg/RechargeFrame/Scroll View/Grid").GetComponent("XUIList") as IXUIList); + Transform transform = base.transform.Find("Bg/RechargeFrame/Scroll View/Grid/TplCard"); + bool flag = transform != null; + if (flag) + { + transform.gameObject.SetActive(false); + } + Transform transform2 = base.transform.Find("Bg/RechargeFrame/Scroll View/Grid/TplDiamond"); + this.m_RechargeDiamondPool.SetupPool(transform2.parent.parent.gameObject, transform2.gameObject, 8u, false); + Transform transform3 = base.transform.Find("Bg/VipFrame/Tabs/Tpl"); + this.m_TabTool.SetupPool(transform3.parent.gameObject, transform3.gameObject, 10u, false); + this.m_TabScrollView = (base.transform.Find("Bg/VipFrame/Tabs").GetComponent("XUIScrollView") as IXUIScrollView); + transform3 = base.transform.Find("Bg/VipFrame/RightView/DescScrollView/Tpl"); + this.m_DescPool.SetupPool(transform3.parent.gameObject, transform3.gameObject, 10u, false); + transform3 = base.transform.Find("Bg/VipFrame/RightView/Item/Tpl"); + this.m_ItemPool.SetupPool(transform3.parent.gameObject, transform3.gameObject, 8u, false); + this.m_GetBtn = (base.transform.Find("Bg/VipFrame/RightView/GetBtn").GetComponent("XUISprite") as IXUISprite); + this.m_GetBtnLabel = (this.m_GetBtn.gameObject.transform.Find("Text").GetComponent("XUILabel") as IXUILabel); + this.m_GetBtnRedPoint = this.m_GetBtn.gameObject.transform.Find("RedPoint").gameObject; + this.m_ViewLevel = (base.transform.Find("Bg/VipFrame/RightView/Name/Level").GetComponent("XUILabel") as IXUILabel); + this.VIPFrame = base.transform.Find("Bg/VipFrame").gameObject; + this.RechargeFrame = base.transform.Find("Bg/RechargeFrame").gameObject; + this._CustomerService = (base.transform.Find("CustomerService").GetComponent("XUIButton") as IXUIButton); + this._wifiBtn = (base.transform.Find("wifi").GetComponent("XUIButton") as IXUIButton); + } + + public override void RegisterEvent() + { + this.m_SwitchBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSwitchBtnClick)); + this.m_GetBtn.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnGetGiftBtnClick)); + this._CustomerService.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCustomClick)); + this._wifiBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnWifiClick)); + } + + protected override void OnShow() + { + base.OnShow(); + this._wifiBtn.SetVisible(XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_3GFree)); + this.SetVipProgressInfo(this._Doc.VipLevel); + this.m_RechargeScrollView.ResetPosition(); + this._Doc.ReqPayAllInfo(); + this.SetSwitchState(); + } + + public void SetSwitchState() + { + this.VIPFrame.SetActive(this._Doc.isVIPShow); + this.RechargeFrame.SetActive(!this._Doc.isVIPShow); + bool isVIPShow = this._Doc.isVIPShow; + if (isVIPShow) + { + this.m_SwitchLabel.SetText(XStringDefineProxy.GetString("RechargeBtnText")); + } + else + { + this.m_SwitchLabel.SetText(XStringDefineProxy.GetString("VIPBtnText")); + } + this.m_SwitchRedPoint.SetActive(!this._Doc.isVIPShow && this._Doc.CalVipRedPoint()); + this.RefreshVIP(); + this.RefreshDatas(); + } + + protected override void OnHide() + { + this._Doc.isVIPShow = false; + XSingleton.singleton.DestroyTextureInActivePool(this.m_RechargeDiamondPool, "Icon"); + for (int i = 0; i < this.m_EffectCache.Count; i++) + { + XSingleton.singleton.DestroyFx(this.m_EffectCache[i], true); + } + this.m_EffectCache.Clear(); + } + + public void SetVipProgressInfo(uint currVipLevel) + { + this.m_CurrVipLevel.SetText(string.Format(XSingleton.singleton.GetString("PAY_VIP_LEVEL"), currVipLevel)); + this.m_NextVipTip.SetText(this._Doc.IsMaxVip(currVipLevel) ? XSingleton.singleton.GetString("PAY_VIP_MAX_TIP") : string.Format(XSingleton.singleton.GetString("PAY_NEXT_VIP_TIP"), this._Doc.LackMoneyToNextVipLevel(currVipLevel), currVipLevel + 1u)); + this.m_NextVipLevel.SetText(this._Doc.IsMaxVip(currVipLevel) ? "" : string.Format(XSingleton.singleton.GetString("PAY_VIP_LEVEL"), currVipLevel + 1u)); + this.m_NextVip.gameObject.SetActive(!this._Doc.IsMaxVip(currVipLevel)); + float num = this._Doc.TotalPay - this._Doc.GetVipRMB(currVipLevel); + uint num2 = this._Doc.GetVipRMB(currVipLevel + 1u) - this._Doc.GetVipRMB(currVipLevel); + float value = (num2 == 0u) ? 0f : (this._Doc.IsMaxVip(currVipLevel) ? 1f : (num / num2)); + this.m_VipProgress.value = value; + this.m_VipProgressValue.SetText(string.Format("{0}/{1}", num, num2)); + this.m_VipProgressValue.gameObject.SetActive(!this._Doc.IsMaxVip(currVipLevel)); + } + + public void RefreshDatas() + { + bool isVIPShow = this._Doc.isVIPShow; + if (!isVIPShow) + { + this.m_RechargeDiamondPool.FakeReturnAll(); + for (int i = 0; i < XRechargeDocument.PayTable.Table.Length; i++) + { + GameObject gameObject = this.m_RechargeDiamondPool.FetchGameObject(false); + gameObject.transform.parent = this.m_RechargeItemList.gameObject.transform; + gameObject.transform.localScale = Vector3.one; + IXUIButton ixuibutton = gameObject.transform.GetComponent("XUIButton") as IXUIButton; + ixuibutton.ID = (ulong)((long)i); + ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnPayItemClick)); + this.RefreshDiamondItem(gameObject, XRechargeDocument.PayTable.Table[i]); + } + this.m_RechargeItemList.Refresh(); + this.m_RechargeDiamondPool.ActualReturnAll(false); + } + } + + private bool OnCustomClick(IXUIButton btn) + { + Dictionary dictionary = new Dictionary(); + RuntimePlatform platform = Application.platform; + if ((int)platform != 8) + { + if ((int)platform != 11) + { + XSingleton.singleton.AddGreenLog("CustomerService-Mall", null, null, null, null, null); + } + else + { + dictionary["url"] = XSingleton.singleton.GetValue("CustomerServiceRechargeAndroid"); + dictionary["screendir"] = "SENSOR"; + XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); + } + } + else + { + dictionary["url"] = XSingleton.singleton.GetValue("CustomerServiceRechargeApple"); + dictionary["screendir"] = "SENSOR"; + XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); + } + return true; + } + + private bool OnWifiClick(IXUIButton btn) + { + AdditionRemindDocument specificDocument = XDocuments.GetSpecificDocument(AdditionRemindDocument.uuID); + specificDocument.Open3GWebPage(); + return true; + } + + private bool OnPayCardClick(IXUIButton btn) + { + int num = (int)btn.ID; + List payCardList = this._Doc.GetPayCardList(); + bool flag = num < payCardList.Count; + if (flag) + { + XRechargeDocument specificDocument = XDocuments.GetSpecificDocument(XRechargeDocument.uuID); + bool flag2 = XSingleton.singleton.XPlatform.Platfrom() == XPlatformType.Android; + if (flag2) + { + specificDocument.SDKSubscribe(payCardList[num].Price, 1, payCardList[num].ServiceCode, payCardList[num].Name, payCardList[num].ParamID, PayParamType.PAY_PARAM_CARD); + } + else + { + bool flag3 = XSingleton.singleton.XPlatform.Platfrom() == XPlatformType.IOS; + if (flag3) + { + int buyNum = (payCardList[num].Type == 1) ? 7 : 30; + specificDocument.SDKSubscribe(payCardList[num].Price, buyNum, payCardList[num].ServiceCode, payCardList[num].Name, payCardList[num].ParamID, PayParamType.PAY_PARAM_CARD); + } + } + } + return true; + } + + private bool OnPayItemClick(IXUIButton btn) + { + int num = (int)btn.ID; + bool flag = num < XRechargeDocument.PayTable.Table.Length; + if (flag) + { + PayListTable.RowData rowData = XRechargeDocument.PayTable.Table[num]; + XRechargeDocument specificDocument = XDocuments.GetSpecificDocument(XRechargeDocument.uuID); + specificDocument.SDKRecharge(rowData.Price, rowData.ParamID, PayParamType.PAY_PARAM_LIST); + } + return true; + } + + public void RefreshDiamondItem(GameObject item, PayListTable.RowData data) + { + IXUISprite ixuisprite = item.transform.Find("Recommend").GetComponent("XUISprite") as IXUISprite; + IXUISprite ixuisprite2 = item.transform.Find("FirstDouble").GetComponent("XUISprite") as IXUISprite; + IXUISprite ixuisprite3 = item.transform.Find("FirstHalf").GetComponent("XUISprite") as IXUISprite; + IXUILabel ixuilabel = item.transform.Find("Price").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel2 = item.transform.Find("Name").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel3 = item.transform.Find("Tip").GetComponent("XUILabel") as IXUILabel; + IXUITexture ixuitexture = item.transform.Find("Icon").GetComponent("XUITexture") as IXUITexture; + ixuitexture.SetTexturePath(data.Icon); + bool flag = data.Effect != ""; + if (flag) + { + Transform parent = item.transform.Find("Icon"); + XFx item2 = XSingleton.singleton.CreateUIFx(data.Effect, parent, false); + this.m_EffectCache.Add(item2); + } + bool flag2 = data.Effect2 != ""; + if (flag2) + { + XFx item3 = XSingleton.singleton.CreateUIFx(data.Effect2, item.transform, false); + this.m_EffectCache.Add(item3); + } + ixuisprite.SetAlpha(0f); + ixuilabel.SetText(string.Format(XSingleton.singleton.GetString("PAY_UNIT"), (float)data.Price / 100f)); + ixuilabel2.SetText(data.Name); + ixuisprite2.SetAlpha(0f); + ixuisprite3.SetAlpha(0f); + ixuilabel3.SetVisible(false); + XRechargeDocument specificDocument = XDocuments.GetSpecificDocument(XRechargeDocument.uuID); + PayMarketingInfo payMarketingInfo; + bool flag3 = specificDocument.FirstPayMarketingInfo.TryGetValue(data.Diamond, out payMarketingInfo); + if (flag3) + { + bool flag4 = payMarketingInfo.sendCount == data.Diamond; + if (flag4) + { + ixuisprite2.SetAlpha(1f); + } + else + { + bool flag5 = payMarketingInfo.sendCount == data.Diamond / 2; + if (flag5) + { + ixuisprite3.SetAlpha(1f); + } + else + { + ixuilabel3.SetVisible(payMarketingInfo.sendCount > 0); + ixuilabel3.SetText(payMarketingInfo.sendCount.ToString()); + } + } + } + } + + public bool OnSwitchBtnClick(IXUIButton sp) + { + this._Doc.isVIPShow = !this._Doc.isVIPShow; + this.SetSwitchState(); + return true; + } + + public void OnGetGiftBtnClick(IXUISprite btn) + { + bool flag = this._Doc.IsGiftGet[this.CurrentClick] == VIPGiftState.UNABLE || this._Doc.IsGiftGet[this.CurrentClick] == VIPGiftState.GET; + if (flag) + { + bool flag2 = this._Doc.IsGiftGet[this.CurrentClick] == VIPGiftState.UNABLE; + if (flag2) + { + XSingleton.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString("VIPGiftGetUnableTips"), this.CurrentClick), "fece00"); + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("VIPGiftGetGetTips"), "fece00"); + } + } + else + { + this._Doc.SendGetVIPGiftQuery(this.CurrentClick); + } + } + + public void RefreshVIP() + { + bool flag = !this._Doc.isVIPShow; + if (!flag) + { + this.CurrentClick = (int)this._Doc.VipLevel; + for (int i = 0; i < this._Doc.IsGiftGet.Count; i++) + { + bool flag2 = this._Doc.IsGiftGet[i] == VIPGiftState.UNGET; + if (flag2) + { + this.CurrentClick = i; + break; + } + } + this.RefreshVIPTabs(); + this.RefreshVIPView(); + } + } + + private void RefreshVIPTabs() + { + this.m_TabTool.ReturnAll(false); + List list = new List(); + this._redPointList.Clear(); + IXUIPanel ixuipanel = this.m_TabTool._tpl.transform.parent.GetComponent("XUIPanel") as IXUIPanel; + int num = this.CurrentClick; + bool flag = false; + bool flag2 = (float)(this.m_TabTool.TplHeight * (this._Doc.IsGiftGet.Count - this.CurrentClick)) < ixuipanel.ClipRange.w; + if (flag2) + { + num = 0; + flag = true; + } + IXUICheckBox ixuicheckBox = null; + for (int i = 0; i < this._Doc.IsGiftGet.Count; i++) + { + GameObject gameObject = this.m_TabTool.FetchGameObject(false); + gameObject.transform.localPosition = new Vector3(this.m_TabTool.TplPos.x, this.m_TabTool.TplPos.y - (float)(this.m_TabTool.TplHeight * (i - num)), 0f); + bool flag3 = !flag && i < this.CurrentClick; + if (flag3) + { + gameObject.SetActive(false); + list.Add(gameObject); + } + IXUILabel ixuilabel = gameObject.transform.Find("Text/T").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(string.Format(XStringDefineProxy.GetString("VIPTabsShow"), i)); + GameObject gameObject2 = gameObject.transform.Find("RedPoint").gameObject; + this._redPointList.Add(gameObject2); + gameObject2.SetActive(this._Doc.IsGiftGet[i] == VIPGiftState.UNGET); + IXUICheckBox ixuicheckBox2 = gameObject.GetComponent("XUICheckBox") as IXUICheckBox; + ixuicheckBox2.ID = (ulong)((long)i); + ixuicheckBox2.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnTabsClick)); + bool flag4 = i == this.CurrentClick; + if (flag4) + { + ixuicheckBox = ixuicheckBox2; + } + } + this.m_TabScrollView.ResetPosition(); + bool flag5 = flag; + if (flag5) + { + bool flag6 = this.CurrentClick != 0; + if (flag6) + { + this.m_TabScrollView.SetPosition(1f); + } + } + else + { + for (int j = 0; j < list.Count; j++) + { + list[j].SetActive(true); + } + } + bool flag7 = ixuicheckBox != null; + if (flag7) + { + ixuicheckBox.bChecked = true; + } + } + + private void RefreshVIPView() + { + this.m_ViewLevel.SetText(this.CurrentClick.ToString()); + VIPTable.RowData byVIP = this._Doc.VIPReader.GetByVIP(this.CurrentClick); + this.RefreshGiftState(this.CurrentClick); + this.m_DescPool.ReturnAll(false); + bool flag = byVIP.VIPTips != null; + if (flag) + { + for (int i = 0; i < byVIP.VIPTips.Length; i++) + { + GameObject gameObject = this.m_DescPool.FetchGameObject(false); + Vector3 tplPos = this.m_DescPool.TplPos; + gameObject.transform.localPosition = new Vector3(tplPos.x, tplPos.y - (float)(this.m_DescPool.TplHeight * i), 0f); + IXUILabel ixuilabel = gameObject.GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(byVIP.VIPTips[i]); + } + } + this.m_ItemPool.ReturnAll(false); + List list = new List(); + List list2; + bool flag2 = XBagDocument.TryGetChestListConf(byVIP.ItemID, out list2); + if (flag2) + { + int j = 0; + int count = list2.Count; + while (j < count) + { + ChestList.RowData rowData = list2[j]; + bool flag3 = !XBagDocument.IsProfMatchedFeable((uint)rowData.Profession, XItemDrawerParam.DefaultProfession, false); + if (!flag3) + { + bool flag4 = XBagDocument.TryGetDropConf(rowData.DropID, ref list); + if (flag4) + { + int k = 0; + int count2 = list.Count; + while (k < count2) + { + ItemList.RowData itemConf = XBagDocument.GetItemConf(list[k].ItemID); + GameObject gameObject2 = this.m_ItemPool.FetchGameObject(false); + Vector3 tplPos2 = this.m_ItemPool.TplPos; + gameObject2.transform.localPosition = new Vector3(tplPos2.x + (float)(this.m_ItemPool.TplWidth * k), tplPos2.y, 0f); + XSingleton.singleton.normalItemDrawer.DrawItem(gameObject2, itemConf, list[k].ItemCount, false); + XSingleton.singleton.normalItemDrawer.OpenClickShowTooltipEvent(gameObject2, list[k].ItemID); + k++; + } + } + } + j++; + } + } + } + + public void RefreshGiftState(int level) + { + bool flag = this._Doc.IsGiftGet.Count == 0; + if (!flag) + { + this.SetGetBtnState(this._Doc.IsGiftGet[this.CurrentClick] == VIPGiftState.UNGET); + bool flag2 = this._Doc.IsGiftGet[this.CurrentClick] == VIPGiftState.GET; + if (flag2) + { + this.m_GetBtnLabel.SetText(XStringDefineProxy.GetString("SRS_FETCHED")); + } + else + { + bool flag3 = (ulong)this._Doc.VipLevel >= (ulong)((long)level); + if (flag3) + { + this.m_GetBtnLabel.SetText(XStringDefineProxy.GetString("SRS_FETCH")); + } + else + { + this.m_GetBtnLabel.SetText(string.Format(XStringDefineProxy.GetString("VIPGiftGetBtnUnableTips"), level)); + } + } + this._redPointList[level].SetActive(this._Doc.IsGiftGet[level] == VIPGiftState.UNGET); + } + } + + private void SetGetBtnState(bool state) + { + this.m_GetBtnRedPoint.SetActive(state); + this.m_GetBtn.SetGrey(state); + } + + public bool OnTabsClick(IXUICheckBox iSp) + { + bool flag = !iSp.bChecked; + bool result; + if (flag) + { + result = true; + } + else + { + this.CurrentClick = (int)iSp.ID; + this.RefreshVIPView(); + result = true; + } + return result; + } + } +} -- cgit v1.1-26-g67d0