void OnConfirmClick() { if (curSelectItem == null) { return; } int count = curSelectItem.GetBuyCount(); if (count <= 0) { return; } Jyx2ShopItem item = curShopData.ShopItems[curSelectItem.GetIndex()]; Jyx2Item itemCfg = ConfigTable.Get <Jyx2Item>(item.Id); if (itemCfg == null) { return; } int moneyCost = count * item.Price; if (GameRuntimeData.Instance.GetMoney() < moneyCost) { GameUtil.DisplayPopinfo("银两不够"); return; } GameRuntimeData.Instance.AddItem(item.Id, count); AddBuyCount(item.Id, count); GameUtil.DisplayPopinfo($"获得物品{itemCfg.Name},数量{count}"); GameRuntimeData.Instance.AddItem(Jyx2Consts.MONEY_ID, -moneyCost); RefreshChild(); RefreshMoney(); }
void OnItemClick(ShopUIItem item) { int index = item.GetIndex(); if (index == curSelectIndex) { return; } curSelectIndex = index; if (curSelectItem) { curSelectItem.SetSelect(false); } curSelectItem = item; curSelectItem.SetSelect(true); RefreshProperty(); }