Ejemplo n.º 1
0
        public static void GuardarPartida()
        {
            string farmName     = PartidaList[0].FarmName;
            string adjustedName = farmName + DateTime.Now.ToString();

            Partida.Almacenar_Partida(PartidaList, adjustedName);


            Alimento.Almacenar_Alimentos(PartidaList[0].PlayerAnimalFood, adjustedName);
            Alimento.Almacenar_Alimentos(PartidaList[0].PlayerFertilizerList, adjustedName);
            Alimento.Almacenar_Alimentos(PartidaList[0].PlayerAnimalWater, adjustedName);
            Alimento.Almacenar_Alimentos(PartidaList[0].PlayerPlantWater, adjustedName);
            Cattle.Almacenar_Ganado(PartidaList[0].PlayerBoughtCattle, adjustedName);
            Map.Almacenar_Mapa(PartidaList[0].Map, adjustedName);
            Plantation.Almacenar_Plantacion(PartidaList[0].PlayerPlantation, adjustedName);
            Remedio.Almacenar_Remedios(PartidaList[0].PlayerVaccines, adjustedName);
            Remedio.Almacenar_Remedios(PartidaList[0].PlayerFungicides, adjustedName);
            Remedio.Almacenar_Remedios(PartidaList[0].PlayerPesticides, adjustedName);
            Remedio.Almacenar_Remedios(PartidaList[0].PlayerHerbicides, adjustedName);
        }
Ejemplo n.º 2
0
        private void CurePurchaseDoneButton_Click(object sender, EventArgs e)
        {
            string chosenCure   = Convert.ToString(FoodPurchaseComboBox.SelectedItem);
            int    cureQuantity = Convert.ToInt32(FoodQuantityNumericUpDown.Value);

            //Hay que restarle el precio de lo gastado al total que tiene el jugador.


            int currentMoney = Juego.PartidaList[0].PlayerCash;
            int type         = 0;

            if (chosenCure == "Vacuna")
            {
                type = 1;
            }
            else if (chosenCure == "Herbicida")
            {
                type = 2;
            }
            else if (chosenCure == "Fungicida")
            {
                type = 3;
            }
            else if (chosenCure == "Pesticida")
            {
                type = 4;
            }

            int curePrice = Juego.Lista_Remedios[type - 1].Price;
            int price     = curePrice * cureQuantity;

            if (currentMoney < price)
            {
                NotEnoughCureMoneyLabel.Visible = true;
                System.Threading.Thread.Sleep(2000);
                NotEnoughCureMoneyLabel.Visible = false;
            }

            else
            {
                Remedio a = new Remedio(500, 50, type);

                if (chosenCure == "Vacuna")
                {
                    for (int i = 1; i <= cureQuantity; i++)
                    {
                        Juego.PartidaList[0].PlayerVaccines.Add(a);
                    }
                }
                else if (chosenCure == "Herbicida")
                {
                    for (int i = 1; i <= cureQuantity; i++)
                    {
                        Juego.PartidaList[0].PlayerHerbicides.Add(a);
                    }
                }
                else if (chosenCure == "Fungicida")
                {
                    for (int i = 1; i <= cureQuantity; i++)
                    {
                        Juego.PartidaList[0].PlayerFungicides.Add(a);
                    }
                }
                else if (chosenCure == "Pesticida")
                {
                    for (int i = 1; i <= cureQuantity; i++)
                    {
                        Juego.PartidaList[0].PlayerFungicides.Add(a);
                    }
                }

                currentMoney = currentMoney - price;
                string currentMoneyText = Convert.ToString(currentMoney);
                ConsMarketMoneyLabel.Text       = "Dinero actual: $" + currentMoneyText;
                Juego.PartidaList[0].PlayerCash = currentMoney;

                CurePurchaseLabel.Visible          = false;
                CurePurchaseComboBox.Visible       = false;
                ConsumableDataGridView1.DataSource = null;
                ConsumableDataGridView1.Visible    = false;
                CurePurchaseButton.Visible         = false;
            }
        }