Ejemplo n.º 1
0
    public void SelectItem()
    {
        ItemListEntry itemEntry = shopList.GetEntry();

        if (!itemEntry || !itemEntry.affordable)
        {
            return;
        }

        if (!promptMode)
        {
            promptMode = true;
            buyPrompt.ShowYesNoPopup((shopList.buyMode) ? "Buy item?" : "Sell item?", true);
        }
        else
        {
            if (buyPrompt.Click(true) == MyPrompt.Result.OK1)
            {
                if (shopList.buyMode)                   // Buy item
                {
                    totalMoney.value -= itemEntry.tuple.cost;
                    playerData.items.Add(itemEntry.tuple.StoreData());
                }
                else                   // Sell item
                {
                    totalMoney.value += (int)(itemEntry.tuple.cost * sellRatio.value);
                    playerData.items.RemoveAt(itemEntry.index);
                    shopList.RemoveEntry();
                }
            }
            shopList.UpdateCost();
            SetupItemInfo();
            DeselectItem();
        }
    }