/// <summary> /// Plants the given crop in this field /// </summary> /// <param name="seed">Crop to plant</param> public void PlantSeed(Seed seed) { if (PlantedSeed == null) { PlantedSeed = seed; PlantedSeed.SetField(this); PlantedSeed.InitializeCrops(); } else throw new Exception("There is already a seed planted!"); }
/// <summary> /// Remove a seed from the inventory /// </summary> /// <param name="seed">Seed to remove from inventory</param> public void RemoveSeedFromInventory(Seed seed) { SeedInventory[seed.Name].Remove(seed); }
/// <summary> /// Adds a seed to the seed inventory /// </summary> /// <param name="seed">Seed to add to the seed inventory</param> public void AddSeedToInventory(Seed seed) { SeedInventory[seed.Name].Add(seed); }
private static void HarvestSelectionDialog(Seed seed) { string anweisung; while(true) { PrintInfoMessage("Which crop do you want to harvest? [enter comma seperated indexes; back]\r\n\r\n" + seed.GetCropInfo()); anweisung = Console.ReadLine(); if (anweisung == "back" || anweisung == "b") break; try { string[] indexStrings = anweisung.Split(','); int[] indexes = Array.ConvertAll(indexStrings, int.Parse); seed.Harvest(indexes); break; } catch(Exception ex) { PrintInfoMessageAndWait(ex.Message); } } }
private static void HarvestFieldDialog(Seed seed) { string anweisung; while (true) { PrintInfoMessage("Which crops to you want to harvest [all; selection; back]\r\n\r\n" + seed.GetCropInfo()); anweisung = Console.ReadLine(); if (anweisung == "all" || anweisung == "a") { HarvestAllDialog(seed); break; } else if (anweisung == "selection" || anweisung == "s") { HarvestSelectionDialog(seed); if (seed.Crops.Count == 0) break; } else if (anweisung == "back" || anweisung == "b") break; } }
private static void HarvestAllDialog(Seed seed) { string anweisung; while (true) { PrintInfoMessage("Do you really want to harvest all crops? They will be put in your inventory. [yes; no]\r\n\r\n" + seed.GetCropInfo()); anweisung = Console.ReadLine(); if (anweisung == "yes" || anweisung == "y") { seed.Harvest(); PrintInfoMessageAndWait("Crops harvested! They have been placed in your inventory."); break; } else if (anweisung == "no" || anweisung == "n") break; } }