Exemplo n.º 1
0
 private void BuyItem(object sender, EventArgs e)
 {
     if (inventory.Coins >= this.item.GetPrice())
     {
         if (this.item.GetName() == "lettuce" || this.item.GetName() == "wheat" || this.item.GetName() == "corn")
         {
             for (int i = 0; i < inventory.seeds.Count; i++)
             {
                 if (this.item.GetName() == inventory.seeds[i].GetName() && inventory.Coins >= inventory.seeds[i].GetPrice())
                 {
                     inventory.seeds[i].SetCount();
                     inventory.Coins -= inventory.seeds[i].GetPrice();
                 }
             }
         }
         else if (this.item.GetName() == "chicken")
         {
             shop.addItem(item);
             inventory.Coins -= item.GetPrice();
         }
         else if (this.item.GetName() == "cow")
         {
             shop.addItem(item);
             inventory.Coins -= item.GetPrice();
         }
         else if (this.item.GetName() == "farmslot" && this.item.GetCount() < 1)
         {
             shop.PrepareLand(item);
             this.item.SetCount();
             this.buyButton.Text = "sold out!";
             inventory.Coins    -= this.item.GetPrice();
         }
     }
 }