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); }
private void EdifOptionsComboBox_SelectedIndexChanged(object sender, EventArgs e) { string selectedItem = EdifOptionsComboBox.Items[EdifOptionsComboBox.SelectedIndex].ToString(); if (selectedItem == "Comprar plantación") { EdifMarketDataGridView.Columns.Add("NameColumn", "Nombre"); EdifMarketDataGridView.Columns.Add("MaturityRateColumn", "Tiempo de madurez"); EdifMarketDataGridView.Columns.Add("PriceColumn", "Precio"); EdifMarketDataGridView.Visible = true; EdifMarketResultLabel.Text = "¿Qué semillas desea comprar?"; EdifMarketResultLabel.Visible = true; List <Seed> seedList = Juego.Lista_Semillas; Seed semillaElegida = Juego.Lista_Semillas[0]; int i = 1; string semillaElegidaNombre = EdifMarketComboBox2.Items[EdifMarketComboBox2.SelectedIndex].ToString(); foreach (Seed s in seedList) { string rowNumber = Convert.ToString(i); string rowName = "Row" + rowNumber; string name = s.Name; EdifMarketDataGridView.Rows.Add(rowName, name); if (name == semillaElegidaNombre) { semillaElegida = s; } i += 1; } foreach (Seed s in seedList) { EdifMarketComboBox2.Items.Add(s.Name); } EdifMarketComboBox2.Visible = true; int price = semillaElegida.BaseSellingPrice; int currentMoney = Juego.PartidaList[0].PlayerCash; if (currentMoney < price) { EdifMarketNotEnoughMoneyLabel.Visible = true; System.Threading.Thread.Sleep(2000); EdifMarketNotEnoughMoneyLabel.Visible = false; } else { Juego.PartidaList[0].PlayerCash = currentMoney - price; Juego.PartidaList[0].PlayerBoughtSeeds.Add(semillaElegida); EdifMarketDataGridView.Visible = false; EdifMarketDataGridView.DataSource = null; EdifMarketResultLabel.Visible = false; EdifMarketComboBox2.Visible = false; EdifMarketComboBox2.Items.Clear(); } } else if (selectedItem == "Comprar ganado") { EdifMarketDataGridView.Visible = true; EdifMarketResultLabel.Text = "Qué ganado desea comprar?"; EdifMarketResultLabel.Visible = true; EdifMarketDataGridView.Columns.Add("NameColumn", "Nombre"); EdifMarketDataGridView.Columns.Add("MaturityRateColumn", "Tiempo de madurez"); EdifMarketDataGridView.Columns.Add("PriceColumn", "Precio"); List <Cattle> cattleList = Juego.Lista_Animales; int i = 1; string chosenCattleName = EdifMarketComboBox2.Items[EdifMarketComboBox2.SelectedIndex].ToString(); Cattle chosenCattle = Juego.Lista_Animales[0]; foreach (Cattle c in cattleList) { string cattleName = c.Name; string rowNumber = Convert.ToString(i); string rowName = "Row" + rowNumber; EdifMarketDataGridView.Rows.Add(rowName, cattleName); if (cattleName == chosenCattleName) { chosenCattle = c; } i += 1; } foreach (Cattle c in cattleList) { EdifMarketComboBox2.Items.Add(c.Name); } EdifMarketComboBox2.Visible = true; int currentMoney = Juego.PartidaList[0].PlayerCash; int price = chosenCattle.PurchasePrice; if (currentMoney < price) { EdifMarketNotEnoughMoneyLabel.Visible = true; System.Threading.Thread.Sleep(2000); EdifMarketNotEnoughMoneyLabel.Visible = false; } else { Juego.PartidaList[0].PlayerCash = currentMoney - price; Juego.PartidaList[0].PlayerBoughtCattle.Add(chosenCattle); EdifMarketDataGridView.Visible = false; EdifMarketDataGridView.DataSource = null; EdifMarketResultLabel.Visible = false; EdifMarketComboBox2.Visible = false; EdifMarketComboBox2.Items.Clear(); } } else if (selectedItem == "Comprar almacenamiento") { EdifMarketDataGridView.Visible = true; EdifMarketDataGridView.Columns.Add("NameColumn", "Nombre"); EdifMarketDataGridView.Columns.Add("PriceColumn", "Precio"); List <StorageBuilding> storageList = Juego.Lista_Almacenamiento; int i = 1; foreach (StorageBuilding sb in storageList) { string name = sb.Name; string rowNumber = Convert.ToString(i); string rowName = "Row" + rowNumber; EdifMarketDataGridView.Rows.Add(rowName, name); EdifMarketComboBox2.Items.Add(name); i += 1; } EdifMarketResultLabel.Visible = true; EdifMarketResultLabel.Text = "¿Que edificio de almacenamiento desea comprar?"; EdifMarketComboBox2.Visible = true; string chosenStorageName = EdifMarketComboBox2.Items[EdifMarketComboBox2.SelectedIndex].ToString(); StorageBuilding chosenStorage = Juego.Lista_Almacenamiento[0]; foreach (StorageBuilding sb in storageList) { string name = sb.Name; if (name == chosenStorageName) { chosenStorage = sb; } } int price = chosenStorage.PurchasePrice; int currentMoney = Juego.PartidaList[0].PlayerCash; if (currentMoney < price) { EdifMarketNotEnoughMoneyLabel.Visible = true; System.Threading.Thread.Sleep(2000); EdifMarketNotEnoughMoneyLabel.Visible = false; } else { Juego.PartidaList[0].PlayerCash = currentMoney - price; Juego.PartidaList[0].playerBoughtStorage.Add(chosenStorage); EdifMarketDataGridView.Visible = false; EdifMarketDataGridView.DataSource = null; EdifMarketResultLabel.Visible = false; EdifMarketComboBox2.Visible = false; EdifMarketComboBox2.Items.Clear(); } } else if (selectedItem == "Vender/destruir edificio") { } }