using Cal.DataTable; using FairyGUI; using System; using System.Collections.Generic; namespace ET { public class MultiShopUIAwakeSyatem : AwakeSystem { public override void Awake(MultiShopUI self) { self.Awake(); } } public class MultiShopUIDestroySyatem : DestroySystem { public override void Destroy(MultiShopUI self) { self.Destroy(); } } public class MultiShopUI : Entity { public FUI_MultiShopUI ui; private Scene zoneScene; private ShopType shopType; public void Awake() { zoneScene = this.ZoneScene(); ui = GetParent(); AwakeAsync().Coroutine(); } private async ETVoid AwakeAsync() { RegisterEvent(); shopType = ShopType.Gem; Refresh(); await ETTask.CompletedTask; } private void RegisterEvent() { this.ui.m_pageList.onClickItem.Set(() => { this.shopType = (ShopType) this.ui.m_pageList.selectedIndex+1; Refresh(); }); } private void Refresh() { ui.m_slotList.RemoveChildrenToPool(); List listItemConfig = MultiShopCategory.Instance.GetByType(this.shopType); if (listItemConfig == null) { Log.Error("config == null"); return; } for (var i = 0; i < listItemConfig.Count; i++) { var btn =this.ui.m_slotList.AddItemFromPool().asButton; int index = i; var config = listItemConfig[index]; btn.icon = UIPackage.GetItemURL(FUIPackage.Bag,BagHelper.GetIconName(config.ItemId).Item2); TabHelper.SetTab(btn, () => { TabHelper.OpenUI(config.ItemId, TabHelper.GetAdditionalPrice(config)); }); //!双击购买 btn.onClick.Set1(async content => { if (content.inputEvent.isDoubleClick) { #if UNITY_STANDALONE if (!content.inputEvent.ctrl) { await SendBuyProto(index,1); return; } FUI_TipUI tipUI = TipHelper.OpenUI("请输入您想购买的数量:", tipType: TipType.DoubleInput); tipUI.m_btnYes.self.onClick.Clear(); tipUI.m_btnYes.self.onClick.Set(TipYesCallBack); tipUI.AddEventCallBack(TipYesCallBack); async void TipYesCallBack() { if (int.TryParse(tipUI.m_IptTxt.text, out int count)) { if (count <= 0) return; await SendBuyProto(index,count); } } #else await SendBuyProto(index, 1); #endif async ETTask SendBuyProto(int index,int count) { M2C_BuyInMultiShop ret = await this.zoneScene.GetComponent().Call(new C2M_BuyInMultiShop { shopType = (int) this.shopType, index = index, count = count }); if (!ret.Message.IsNullOrEmpty()) { TipHelper.OpenUI(ret.Message); return; } Game.EventSystem.Publish_Sync(new ET.EventType.UpdateBagUI { list = ret.BagMapList }); } } }); } } public void Destroy() { } } }