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/XMystShopView.cs | 142 +++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XMystShopView.cs (limited to 'Client/Assets/Scripts/XMainClient/XMystShopView.cs') diff --git a/Client/Assets/Scripts/XMainClient/XMystShopView.cs b/Client/Assets/Scripts/XMainClient/XMystShopView.cs new file mode 100644 index 00000000..b95c7157 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XMystShopView.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XMystShopView : DlgHandlerBase + { + private XUIPool m_ShopItemPool = new XUIPool(XSingleton.singleton.m_uiTool); + + private List m_ShopItemList = new List(); + + private XMystShopDocument _doc = null; + + private GameObject refreshConfirmPanel; + + private IXUIButton refreshConfirmOK; + + private IXUIButton refreshConfirmCancel; + + protected override void Init() + { + base.Init(); + this._doc = XDocuments.GetSpecificDocument(XMystShopDocument.uuID); + this._doc.View = this; + GameObject gameObject = base.PanelObject.transform.Find("Panel").gameObject; + GameObject gameObject2 = base.PanelObject.transform.Find("Panel/ShopItemTpl").gameObject; + this.m_ShopItemPool.SetupPool(gameObject, gameObject2, 6u, false); + string[] array = XSingleton.singleton.GetValue("shopTimming").Split(XGlobalConfig.ListSeparator); + string text = ""; + foreach (string str in array) + { + text = text + str + ":00 "; + } + IXUILabel ixuilabel = base.PanelObject.transform.Find("Title").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(XStringDefineProxy.GetString("MYSTSHOP_REFRESH_TIME", new object[] + { + text + })); + this.refreshConfirmPanel = base.PanelObject.transform.Find("RefreshConfirm").gameObject; + this.refreshConfirmOK = (this.refreshConfirmPanel.transform.Find("P/OK").GetComponent("XUIButton") as IXUIButton); + this.refreshConfirmCancel = (this.refreshConfirmPanel.transform.Find("P/Cancel").GetComponent("XUIButton") as IXUIButton); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + IXUIButton ixuibutton = base.PanelObject.transform.Find("BtnRefresh").GetComponent("XUIButton") as IXUIButton; + ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRefreshBtnClicked)); + this.refreshConfirmOK.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRefreshBtnOKClicked)); + this.refreshConfirmCancel.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRefreshBtnCancelClicked)); + } + + protected override void OnShow() + { + base.OnShow(); + this._doc.ReqOperateMystShop(MythShopOP.MythShopQuery, 0); + this.refreshConfirmPanel.SetActive(false); + } + + protected override void OnHide() + { + base.OnHide(); + this.refreshConfirmPanel.SetActive(false); + } + + public override void OnUnload() + { + this._doc.View = null; + base.OnUnload(); + } + + public void RefreshGoodsList() + { + List goodsList = this._doc.GoodsList; + int num = Math.Max(goodsList.Count, this.m_ShopItemList.Count); + for (int i = this.m_ShopItemList.Count; i < num; i++) + { + GameObject gameObject = this.m_ShopItemPool.FetchGameObject(false); + this.m_ShopItemList.Add(gameObject); + IXUIButton ixuibutton = gameObject.transform.Find("BtnBuy").GetComponent("XUIButton") as IXUIButton; + IXUISprite ixuisprite = gameObject.transform.Find("Item/Icon").GetComponent("XUISprite") as IXUISprite; + ixuibutton.ID = (ulong)((long)i); + ixuisprite.ID = (ulong)((long)i); + ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnItemBuyClicked)); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnItemIconClicked)); + } + num = Math.Min(goodsList.Count, this.m_ShopItemList.Count); + for (int j = this.m_ShopItemList.Count - 1; j >= num; j--) + { + GameObject go = this.m_ShopItemList[j]; + this.m_ShopItemList.RemoveAt(j); + this.m_ShopItemPool.ReturnInstance(go, false); + } + for (int k = 0; k < goodsList.Count; k++) + { + XMystShopGoods goods = goodsList[k]; + GameObject gameObject2 = this.m_ShopItemList[k]; + this.UpdateGoodsInfo(goods, gameObject2); + gameObject2.transform.localPosition = new Vector3(this.m_ShopItemPool.TplPos.x + (float)(k % 3 * this.m_ShopItemPool.TplWidth), this.m_ShopItemPool.TplPos.y - (float)(k / 3 * this.m_ShopItemPool.TplHeight), this.m_ShopItemPool.TplPos.z); + } + } + + private void UpdateGoodsInfo(XMystShopGoods goods, GameObject shopItem) + { + } + + private void OnItemIconClicked(IXUISprite iSp) + { + } + + private bool OnItemBuyClicked(IXUIButton btn) + { + this._doc.ReqOperateMystShop(MythShopOP.MythShopBuy, (int)btn.ID); + return true; + } + + private bool OnRefreshBtnClicked(IXUIButton btn) + { + this.refreshConfirmPanel.SetActive(true); + IXUILabel ixuilabel = this.refreshConfirmPanel.transform.Find("P/Cost").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(this._doc.refreshCost.ToString()); + return true; + } + + private bool OnRefreshBtnOKClicked(IXUIButton btn) + { + this.refreshConfirmPanel.SetActive(false); + this._doc.ReqOperateMystShop(MythShopOP.MythShopRefresh, 0); + return true; + } + + private bool OnRefreshBtnCancelClicked(IXUIButton btn) + { + this.refreshConfirmPanel.SetActive(false); + return true; + } + } +} -- cgit v1.1-26-g67d0