zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/HotfixView/UI/MultiShopUI/MultiShopUI.cs

121 lines
4.0 KiB
C#

using Cal.DataTable;
using FairyGUI;
using System;
using System.Collections.Generic;
namespace ET
{
public class MultiShopUIAwakeSyatem : AwakeSystem<MultiShopUI>
{
public override void Awake(MultiShopUI self)
{
self.Awake();
}
}
public class MultiShopUIDestroySyatem : DestroySystem<MultiShopUI>
{
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<FUI_MultiShopUI>();
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<MultiShop> 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_BuyInShop ret = await this.zoneScene.GetComponent<SessionComponent>().Call<M2C_BuyInShop>(new C2M_BuyInShop { PageIndex = this.ui.m_pageList.selectedIndex, SlotIndex = 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()
{
}
}
}