예제 #1
0
    public void Sell(int index)
    {
        if (index <= 11)
        {
            NonConsumable itm = items [index];
            if (itm.price <= playerInventory.oro)
            {
                if (!itm.bought)
                {
                    playerInventory.items.Add(itm);
                    playerInventory.oro -= itm.price;
                    items[index].bought  = true;
                    ui.CompraExitosa(index);
                }
                else
                {
                    ui.LoTienes();
                }
            }
            else
            {
                ui.SinDinero();
            }
        }
        else
        {
            if (index == 12)
            {
                if (playerInventory.powerUps [0].price < playerInventory.oro)
                {
                    playerInventory.powerUps [0].cantidad += 1;
                    playerInventory.oro -= playerInventory.powerUps [0].price;
                    ui.CompraExitosa(index);
                }
                else
                {
                    ui.SinDinero();
                }
            }

            if (index == 13)
            {
                if (playerInventory.powerUps [1].price < playerInventory.oro)
                {
                    playerInventory.powerUps [1].cantidad += 1;
                    playerInventory.oro -= playerInventory.powerUps [1].price;
                    ui.CompraExitosa(index);
                }
                else
                {
                    ui.SinDinero();
                }
            }

            if (index == 14)
            {
                if (playerInventory.powerUps [2].price < playerInventory.oro)
                {
                    playerInventory.powerUps [2].cantidad += 1;
                    playerInventory.oro -= playerInventory.powerUps [2].price;
                    ui.CompraExitosa(index);
                }
                else
                {
                    ui.SinDinero();
                }
            }
        }
    }