示例#1
0
    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();
    }
示例#2
0
    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();
    }