public async Task <IActionResult> Edit(int id, [Bind("Id,Produkt,Antal,Enhet,Medelande")] Vegetables vegetables) { if (id != vegetables.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vegetables); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VegetablesExists(vegetables.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(vegetables)); }
IEnumerator startCooking() { int veg = currentLockedPlayer.PlayerInventory.peekNextItem(); if (!Vegetables.isRawVegetable(veg))// if only it is vegetable then allow cooking. { resetData(); yield break; } // Enable salad canvas if (!saladCanvas.gameObject.activeSelf) { saladCanvas.gameObject.SetActive(true); } veg = currentLockedPlayer.PlayerInventory.getNextItem(); currentStack |= (int)Vegies.oneItemSaladHandle;// Adding salad handler enum value preparingVegData = ChefSaladManager.getVegetableData(veg); prepareTimeLeft = preparingVegData.preparationTime; // Wait and pass on this frame so calculation start from next frame. yield return(new WaitForEndOfFrame()); while (true) { // Moving player to stove's preparation point if ((stoveStandingSpot.position - currentLockedPlayer.transform.position).magnitude > 0.02) { currentLockedPlayer.transform.position += 2 * (stoveStandingSpot.position - currentLockedPlayer.transform.position) * Time.deltaTime; currentLockedPlayer.transform.rotation = stoveStandingSpot.rotation; } prepareTimeLeft -= Time.deltaTime; if (prepareTimeLeft <= 0)// if preparation time ends it means vegetable is prepared. { ingredientPrepared(veg); // Check for if player has more vegetable to add if yes then continue with next item he has. if (currentLockedPlayer.PlayerInventory.hasAnyItem()) { veg = currentLockedPlayer.PlayerInventory.peekNextItem(); // if next ingredient is already added then stop cooking or if salad still has space to add ingredient if ((currentStack & veg) != 0 || currentIngredientCount >= ChefSaladManager.MAX_INGREDIENT_COUNT) { break; } veg = currentLockedPlayer.PlayerInventory.getNextItem(); preparingVegData = ChefSaladManager.getVegetableData(veg); prepareTimeLeft = preparingVegData.preparationTime; } else { break; } } yield return(new WaitForEndOfFrame()); } resetData(); }
public void Display() { Console.WriteLine($"Bread: {Bread.ToString()}"); Console.WriteLine($"Meat: {Meat.ToString()}"); Console.WriteLine($"Vegetables: {Vegetables.ToString()}"); Console.WriteLine($"Sauces: {SauceTypes.ToString()}"); }
public override int GetHashCode() => BreadType.GetHashCode() ^ CheeseType.GetHashCode() ^ HasMayo.GetHashCode() ^ HasMustard.GetHashCode() ^ IsToasted.GetHashCode() ^ MeatType.GetHashCode() ^ Vegetables.GetHashCode();
public async Task <IActionResult> Edit(int id, [Bind("Id,VegetableName,VegetableForm,AvgRetailPrice,PreparationYieldFactor,Sizeofcupequivalent,AvgPricepercupequivalent")] Vegetables vegetables) { if (id != vegetables.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vegetables); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VegetablesExists(vegetables.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vegetables)); }
public Order(Bread bread, Meat meat, Vegetables vegetables) { Sandwich = new Recipe( bread, meat, vegetables); }
public Vegetables GetVegetable() // this will either get me something that is already isActive seen in our vegetables script or it will create a new instance { Vegetables v = veggies.Find(x => !x.IsActive); // this was quite difficult basically this looks through the list of veggies to find the first one that is not active, x being the veggie its looking at right now and also setting vegetable to variable v // if the veggie is not active right now return the veggie to v field and stop executing. if (v == null) { // if we haven't been able to find a veggie because they are all being used right now v = Instantiate(vegetablesPrefab).GetComponent <Vegetables>(); // create a new instance of a vegetable using a prefab veggies.Add(v); v = Instantiate(onionPrefab).GetComponent <Vegetables>(); veggies.Add(v); v = Instantiate(carrotPrefab).GetComponent <Vegetables>(); veggies.Add(v); v = Instantiate(tomatoPrefab).GetComponent <Vegetables>(); veggies.Add(v); v = Instantiate(brocPrefab).GetComponent <Vegetables>(); veggies.Add(v); v = Instantiate(Bomb).GetComponent <Vegetables>(); // create a new instance of a vegetable using a prefab veggies.Add(v); } return(v); // return vegetables ending our pooling of vegetables saving memory by using prefabs for optimisation purposes. }
public override void interact(GameObject interactor) { Player player = interactor.GetComponent <Player>(); int item = player.PlayerInventory.getNextItem(); // if is vegetable then cost can be determined from vegetable data if (Vegetables.isRawVegetable(item)) { VegetableData vegData = ChefSaladManager.getVegetableData(item); if (onItemTrashed != null) { onItemTrashed.Invoke(player.GetId, vegData.Penalty); } } else // if it is salad we get each individual vegetable by bit shifting vegetable integer and finding its vegetable data { float cost = 0; int itemMask = item; for (int i = 0; i < (int)Vegies.count; i++) { if ((itemMask & 1) > 0) { int veg = (int)Mathf.Pow(2, i); VegetableData vegData = ChefSaladManager.getVegetableData(veg); cost += vegData.Penalty; } itemMask >>= 1; } if (onItemTrashed != null) { onItemTrashed.Invoke(player.GetId, cost); } } }
private void Update() { if (isPaused) { return; // not running if its paused } //Debug.Log (Input.mousePosition); // debug the mouse position if (Time.time - lastSpawn > normalSpawn) // if the last time a veggie was spawned is greater than the normal spawn time of 2f than spawn a new veggie { Vegetables v = GetVegetable(); float ranX = Random.Range(-3.65f, 6.65f); // spawn towards left then go toward right side v.startVeggie(Random.Range(3.85f, 5.75f), ranX, -ranX); // picking up the values of startVeggie and giving them values such as velocity which can be seen in vegetables script lastSpawn = Time.time; // normalspawn time = running time of the game } if (Input.GetMouseButton(0)) // check if im holding the left click or touch on a device { Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); // transferring the screen coordinates using the mouse using unity screentoworldpoint allowing them to show up in our world or game // return vector 3 x and y position // Physics2D.RaycastAll(new Vector2(pos.x,pos.y),Camera.main.transform.forward, pos.z = -1; trail.position = pos; Collider2D[] thisFramesVeggie = Physics2D.OverlapPointAll(new Vector2(pos.x, pos.y), LayerMask.GetMask("Vegetables")); // overlapPointAll returns us a 2d collider array // everytime our finger is dragged on the screen check where finger is and check to see was a collider hit that are vegetables // if we do hit them then store all of them in an array //Debug.Log (Input.mousePosition); //Debug.Log((Input.mousePosition - lastMousePosition).sqrMagnitude)) if ((Input.mousePosition - lastMousePosition).sqrMagnitude > SLICE_FORCE) { // if the sqMagnitude is bigger than 9.0f 3 squared is 9 speed foreach (Collider2D c2 in thisFramesVeggie) { for (int i = 0; i < veggieCollider.Length; i++) { if (c2 == veggieCollider [i]) { c2.GetComponent <Vegetables> ().SlicingVeggie(); //Debug.Log ("Hit"); } } } // c2 is a collider //Debug.Log(c2.name); // debugging hit detection } lastMousePosition = Input.mousePosition; veggieCollider = thisFramesVeggie; //Physics2D.RaycastAll(new Vector2(camPos.x,camPos.y), Camera.main.transform.forward // Physics2D.RaycastAll(new Vector2(pos.x,pos.y), } }
/// <summary> /// Gets first item that is either vegetable or salad based on boolean passed in. /// </summary> /// <param name="isVegetable">True if need to find first vegetable else for salad</param> /// <returns>Found first item else will be zero(none)</returns> public int getFirstItem(bool isVegetable) { List <int> dataToAdd = new List <int>(); int[] items = getItemsInArray(); int retItem = 0; foreach (int item in items) { if (!(isVegetable ^ Vegetables.isRawVegetable(item)) && retItem == 0) { retItem = item; } else { dataToAdd.Add(item); } } stackItems.Clear(); foreach (int item in dataToAdd) { stackItems.Enqueue(item); } if (retItem != 0 && onInventoryChanged != null) { onInventoryChanged.Invoke(); } return(retItem); }
public async Task <IActionResult> Create([Bind("Id,Produkt,Antal,Enhet,Medelande")] Vegetables vegetables) { if (ModelState.IsValid) { _context.Add(vegetables); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(vegetables)); }
public async Task <IActionResult> Create([Bind("Id,VegetableName,VegetableForm,AvgRetailPrice,PreparationYieldFactor,Sizeofcupequivalent,AvgPricepercupequivalent")] Vegetables vegetables) { if (ModelState.IsValid) { _context.Add(vegetables); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(vegetables)); }
static void Main() { var s = new Sandwich(); var b = new Bread(); var m = new Meat(); var v = new Vegetables(); s.Add(b); s.Add(m); s.Add(v); //Application.Run(new Game()); }
public MainContext(DbContextOptions <MainContext> options) : base(options) { if (!Dishes.Any()) { Dishes.Add(new Dish() { Name = "Plate" }); Dishes.Add(new Dish() { Name = "Fork" }); Dishes.Add(new Dish() { Name = "Knife" }); SaveChanges(); } if (!Fruits.Any()) { Fruits.Add(new Fruit() { Name = "Apple" }); Fruits.Add(new Fruit() { Name = "Orange" }); Fruits.Add(new Fruit() { Name = "Kiwi" }); SaveChanges(); } if (!Vegetables.Any()) { Vegetables.Add(new Vegetable() { Name = "Cucumber" }); Vegetables.Add(new Vegetable() { Name = "Tomato" }); Vegetables.Add(new Vegetable() { Name = "Carrot" }); SaveChanges(); } }
static ApplicationLogic() { meat = new Meat(); fruit = new Fruits(); nuts = new Nuts(); vegetables = new Vegetables(); fish = new Fish(); cereals = new Cereals(); bread = new Bread(); alchohol = new Alchohol(); softDrinks = new SoftDrinks(); user = new User("Winnie the Pooh"); }
public override string ToString() { var burgerBuilder = new StringBuilder(); if (!string.IsNullOrWhiteSpace(Bun)) { burgerBuilder.Append(Bun); burgerBuilder.Append(" "); } if (!string.IsNullOrWhiteSpace(Protein)) { burgerBuilder.Append(Protein); burgerBuilder.Append(" "); } if (!string.IsNullOrWhiteSpace(Cheese)) { burgerBuilder.Append(Cheese); burgerBuilder.Append(" "); } if (!string.IsNullOrWhiteSpace(Avocado)) { burgerBuilder.Append(Avocado); burgerBuilder.Append(" "); } if (Condiments != null) { foreach (var condiment in Condiments.Where(x => !string.IsNullOrWhiteSpace(x))) { burgerBuilder.Append(condiment); burgerBuilder.Append(" "); } } if (Vegetables != null) { foreach (var vegetable in Vegetables.Where(x => !string.IsNullOrWhiteSpace(x))) { burgerBuilder.Append(vegetable); burgerBuilder.Append(" "); } } if (Extras != null) { foreach (var extra in Extras.Where(x => !string.IsNullOrWhiteSpace(x))) { burgerBuilder.Append(extra); burgerBuilder.Append(" "); } } return(burgerBuilder.ToString().TrimEnd()); }
public override bool Equals(object obj) { if (obj is Sandwich sandwich) { return(Equals(BreadType, sandwich.BreadType) && Equals(CheeseType, sandwich.CheeseType) && Equals(HasMayo, sandwich.HasMayo) && Equals(HasMustard, sandwich.HasMustard) && Equals(IsToasted, sandwich.IsToasted) && Equals(MeatType, sandwich.MeatType) && Vegetables.SequenceEqual(sandwich.Vegetables)); } return(base.Equals(obj)); }
/// <summary> /// Refreshes and recreates inventory data of player /// </summary> public void inventoryRefresh() { if (playerInventory == null) { return; } int[] items = playerInventory.getItemsInArray(); while (inventoryPanel.transform.childCount != 0) { GameObject go = inventoryPanel.transform.GetChild(0).gameObject; go.transform.SetParent(null); Destroy(go); } if (reverseInventory) { Array.Reverse(items); } foreach (int item in items) { if (Vegetables.isRawVegetable(item)) { GameObject go = Instantiate(vegItemIconPrefab); SaladIngredientCanvasScript saladIngredient = go.GetComponent <SaladIngredientCanvasScript>(); saladIngredient.itemImageSprite.sprite = ChefSaladManager.getVegetableData(item).vegTexture; go.transform.SetParent(inventoryPanel.transform); } else { GameObject go = Instantiate(saladItemIconPrefab); SaladCanvasScript saladCanvas = go.GetComponent <SaladCanvasScript>(); go.transform.SetParent(inventoryPanel.transform); int itemMask = item; for (int i = 0; i < (int)Vegies.count; i++) { if ((itemMask & 1) > 0) { int veg = (int)Mathf.Pow(2, i); saladCanvas.addItem(ChefSaladManager.getVegetableData(veg)); } itemMask >>= 1; } } } }
private void ReloadVegetables(List <Vegetable> vegetables) { Vegetables.Clear(); foreach (var vegetable in vegetables.OrderBy(v => v.Description)) { Vegetables.Add(new VegetableItemViewModel { Description = vegetable.Description, VegetableId = vegetable.VegetableId, Price = vegetable.Price, Image = vegetable.Image, IsActive = vegetable.IsActive, LastPurchase = vegetable.LastPurchase, Observation = vegetable.Observation, }); } }
static void Main(string[] args) { IVegetable carrot = new Carrot(); IVegetable patato = new Patato(); IVegetable paper = new Paper(); IVegetable vegetables = new Vegetables(); IAppearance bowl = new Bowl(); IAppearance steamer = new Steamer(); Chef chef = new Chef(); chef.Wash(); chef.Cut(); chef.Prepare(bowl); chef.Cook(steamer); chef.Serve(); }
/// <summary> /// Checks if any item in inventory is a vegetables /// </summary> /// <returns>true if Inventory has any vegetables.</returns> public bool hasAnyVegetables() { if (!hasAnyItem()) { return(false); } if (Vegetables.isRawVegetable(peekNextItem())) { return(true); } foreach (int item in getItemsInArray()) { if (Vegetables.isRawVegetable(item)) { return(true); } } return(false); }
private Product AddNewProduct(string[] splittedValues) //return kann parent PRODUCT sein und alle Kinder auch zurückgeben!!!!! { Product newProd; //initialisieren ohne zuweisung GEHT!!! string type = splittedValues[4].ToLower(); if (type == "alcohol") { newProd = new Alcohol(); } else if (type == "fruits") { newProd = new Fruits(); } else if (type == "sweets") { newProd = new Sweets(); } else { newProd = new Vegetables(); } newProd.ID = splittedValues[0]; newProd.Cost = double.Parse(splittedValues[1].Replace("€", "")); newProd.Name = splittedValues[2]; newProd.Usebefore = splittedValues[3]; newProd.Type = type; if (splittedValues[5] == "normal") { newProd.Storagetype = Storagetype.NORMAL; } else if (splittedValues[5] == "fridge") { newProd.Storagetype = Storagetype.FRIDGE; } else if (splittedValues[5] == "freezer") { newProd.Storagetype = Storagetype.FREEZER; } return(newProd); }
public void PopulateItems() { Vegetables.Add(new Vegetable { Name = "Yarrow", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Pumpkins", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Cabbage", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Spinach", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Wheat Grass", Category = "Leafy and Salad" }); Vegetables.Add(new Vegetable { Name = "Horse gram", Category = "Beans" }); Vegetables.Add(new Vegetable { Name = "Chickpea", Category = "Beans" }); Vegetables.Add(new Vegetable { Name = "Green bean", Category = "Beans" }); Vegetables.Add(new Vegetable { Name = "Garlic", Category = "Bulb and Stem" }); Vegetables.Add(new Vegetable { Name = "Onion", Category = "Bulb and Stem" }); Vegetables.Add(new Vegetable { Name = "Nopal", Category = "Bulb and Stem" }); SortItems(); }
private void InitialiseKeyboard(IWindowManipulationService windowManipulationService) { if (Settings.Default.ConversationOnlyMode) { Keyboard = new ConversationAlpha(null); windowManipulationService.Maximise(); } else { switch (Settings.Default.StartupKeyboard) { case Enums.Keyboards.Alpha: Keyboard = new Alpha(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); windowManipulationService.Maximise(); break; case Enums.Keyboards.ConversationAlpha: Keyboard = new ConversationAlpha(() => { Keyboard = new Menu(() => Keyboard = new Alpha()); mainWindowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); }); windowManipulationService.Maximise(); break; case Enums.Keyboards.ConversationNumericAndSymbols: Keyboard = new ConversationNumericAndSymbols(() => { Keyboard = new Menu(() => Keyboard = new Alpha()); mainWindowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); }); windowManipulationService.Maximise(); break; case Enums.Keyboards.Currencies1: Keyboard = new Currencies1(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.Currencies2: Keyboard = new Currencies2(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.Diacritics1: Keyboard = new Diacritics1(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.Diacritics2: Keyboard = new Diacritics2(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.Diacritics3: Keyboard = new Diacritics3(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.Food: Keyboard = new Food(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.Menu: Keyboard = new Menu(() => Keyboard = new Alpha()); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.Minimised: Keyboard = new Minimised(() => { Keyboard = new Menu(() => Keyboard = new Alpha()); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); }); windowManipulationService.Minimise(); break; case Enums.Keyboards.Mouse: Keyboard = new Mouse(() => Keyboard = new Menu(() => Keyboard = new Alpha())); windowManipulationService.Restore(); if (Settings.Default.MouseKeyboardDockSize == DockSizes.Full) { mainWindowManipulationService.ResizeDockToFull(); } else { mainWindowManipulationService.ResizeDockToCollapsed(); } break; case Enums.Keyboards.NumericAndSymbols1: Keyboard = new NumericAndSymbols1(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.NumericAndSymbols2: Keyboard = new NumericAndSymbols2(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.NumericAndSymbols3: Keyboard = new NumericAndSymbols3(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.PhysicalKeys: Keyboard = new PhysicalKeys(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.SizeAndPosition: Keyboard = new SizeAndPosition(() => Keyboard = new Menu(() => Keyboard = new Alpha())); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.emotionKeyboardKeyboard: Keyboard = new emotionKeyboard(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.PeopleKeyboard: Keyboard = new People(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.SportKeyboard: Keyboard = new Sport(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.CountriesKeyboard: Keyboard = new Countries(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.PlacesKeyboard: Keyboard = new Places(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.WeatherKeyboard: Keyboard = new Weather(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.BathroomKeyboard: Keyboard = new Bathroom(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.HouseholdKeyboard: Keyboard = new Household(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.ClothesKeyboard: Keyboard = new Clothes(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.EntertainmentKeyboard: Keyboard = new Entertainment(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.TimeKeyboard: Keyboard = new Time(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.GesturesKeyboard: Keyboard = new Gestures(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.AnimalsKeyboard: Keyboard = new Animals(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.DrinksKeyboard: Keyboard = new Drinks(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.FruitsKeyboard: Keyboard = new Fruits(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; case Enums.Keyboards.VegetablesKeyboard: Keyboard = new Vegetables(); windowManipulationService.Restore(); mainWindowManipulationService.ResizeDockToFull(); break; } } }
private void Peel(Vegetables vegetable) { vegetable.IsPeeled = true; }
public void toneDiet() //Tone muscle diet specifications { vegAmt = Vegetables.high; proAmt = Protein.medium; fatAmt = Fat.low; }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.Text == "Фрукты") { double price = double.Parse(textBox1.Text); int count = int.Parse(textBox2.Text); AProducts item = new Fruits(price, count, (FruitType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem); ICrud <Fruits> crud = new ICrudFruit(); crud.Create((Fruits)item); } else if (comboBox1.Text == "Овощи") { double price = double.Parse(textBox1.Text); int count = int.Parse(textBox2.Text); AProducts item = new Vegetables(price, count, (VegetableType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem); ICrud <Vegetables> crud = new ICrudVegetable(); crud.Create((Vegetables)item); } else if (comboBox1.Text == "Зелень") { double price = double.Parse(textBox1.Text); int count = int.Parse(textBox2.Text); AProducts item = new Herbaceous(price, count, (HerbaceousType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem); ICrud <Herbaceous> crud = new ICrudHerbaceous(); crud.Create((Herbaceous)item); } else if (comboBox1.Text == "Говядина") { double price = double.Parse(textBox1.Text); int count = int.Parse(textBox2.Text); AProducts item = new Beef(price, count, (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem); ICrud <Beef> crud = new ICrudBeef(); crud.Create((Beef)item); } if (comboBox1.Text == "Свинина") { double price = double.Parse(textBox1.Text); int count = int.Parse(textBox2.Text); AProducts item = new Pork(price, count, (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem); ICrud <Pork> crud = new ICrudPork(); crud.Create((Pork)item); } else if (comboBox1.Text == "Курица") { double price = double.Parse(textBox1.Text); int count = int.Parse(textBox2.Text); AProducts item = new Chicken(price, count, (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem); ICrud <Chicken> crud = new ICrudChicken(); crud.Create((Chicken)item); } else if (comboBox1.Text == "Рыба") { double price = double.Parse(textBox1.Text); int count = int.Parse(textBox2.Text); AProducts item = new Fish(price, count, (FishName)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem); ICrud <Fish> crud = new ICrudFish(); crud.Create((Fish)item); } }
public void bulkDiet() // Bulking diet specifications { vegAmt = Vegetables.medium; proAmt = Protein.high; fatAmt = Fat.high; }
private void Cut(Vegetables vegetable) { vegetable.IsCut = true; }
public void AddVegetable(Vegetable v) => Vegetables.Add(v);
public double CalculateDiet() { int total_items = 7; double fruit_score = 0, veg_score = 0, fish_score = 0, wg_score = 0, fastfood_score = 0, sweets_score = 0, beverage_score = 0; #region Fruit if (Fruits == null) { total_items--; } else if (Fruits != null && Fruits.Trim().Equals("Often")) { fruit_score = 10; } else if (Fruits != null && Fruits.Trim().Equals("Sometimes")) { fruit_score = 5; } else if (Fruits != null && Fruits.Trim().Equals("Rarely")) { fruit_score = 0; } #endregion #region Vegetables if (Vegetables == null) { total_items--; } else if (Vegetables != null && Vegetables.Trim().Equals("Often")) { veg_score = 10; } else if (Vegetables != null && Vegetables.Trim().Equals("Sometimes")) { veg_score = 5; } else if (Vegetables != null && Vegetables.Trim().Equals("Rarely")) { veg_score = 0; } #endregion #region Fish if (Fish == null) { total_items--; } else if (Fish != null && Fish.Trim().Equals("Often")) { fish_score = 10; } else if (Fish != null && Fish.Trim().Equals("Sometimes")) { fish_score = 5; } else if (Fish != null && Fish.Trim().Equals("Rarely")) { fish_score = 0; } #endregion #region Wholegrain if (Wholegrain == null) { total_items--; } else if (Wholegrain != null && Wholegrain.Trim().Equals("Often")) { wg_score = 10; } else if (Wholegrain != null && Wholegrain.Trim().Equals("Sometimes")) { wg_score = 5; } else if (Wholegrain != null && Wholegrain.Trim().Equals("Rarely")) { wg_score = 0; } #endregion #region Fastfood if (Fastfood == null) { total_items--; } else if (Fastfood != null && Fastfood.Trim().Equals("Often")) { fastfood_score = 0; } else if (Fastfood != null && Fastfood.Trim().Equals("Sometimes")) { fastfood_score = 5; } else if (Fastfood != null && Fastfood.Trim().Equals("Rarely")) { fastfood_score = 10; } #endregion #region Sweets if (Sweets == null) { total_items--; } else if (Sweets != null && Sweets.Trim().Equals("Often")) { sweets_score = 0; } else if (Sweets != null && Sweets.Trim().Equals("Sometimes")) { sweets_score = 5; } else if (Sweets != null && Sweets.Trim().Equals("Rarely")) { sweets_score = 10; } #endregion #region Beverages if (Beverages == null) { total_items--; } else if (Beverages != null && Beverages.Trim().Equals("Often")) { beverage_score = 0; } else if (Beverages != null && Beverages.Trim().Equals("Sometimes")) { beverage_score = 5; } else if (Beverages != null && Beverages.Trim().Equals("Rarely")) { beverage_score = 10; } #endregion double total_score = 0, score_percent = 0; if (total_items != 0) { total_score = (fruit_score + veg_score + fish_score + wg_score + fastfood_score + sweets_score + beverage_score) / total_items; score_percent = total_score * 10; } return(score_percent); }
public void Update(TimeSpan elapsed) { _elapsedSinceLastVegetableGeneration += elapsed; _elapsedSinceLastDataRefreshTime += elapsed; foreach (var specie in Population) { var newGeneration = new List <Animal>(); foreach (var animal in specie.Value) { // He could die due to another animal attack if (_evaluator.IsDead(animal)) { continue; } // * Movement bool moved = false; // Hunger is always the priority if (animal.IsHungry) { if (animal.Diet == Diet.Herbivore) { var vegetableNearby = _evaluator.FirstVegetableInLineOfSight(animal); if (vegetableNearby != null) { moved = _evaluator.Approach(animal, vegetableNearby, elapsed); if (_evaluator.IsEnoughCloseToInteract(animal, vegetableNearby)) { _evaluator.Eat(animal, vegetableNearby); } } } else if (animal.Diet == Diet.Carnivorous) { var enemyNearby = _evaluator.FirstEnemyInLineOfSight(animal); if (enemyNearby != null) { moved = _evaluator.Approach(animal, enemyNearby, elapsed); if (_evaluator.IsEnoughCloseToInteract(animal, enemyNearby)) { _evaluator.Attack(animal, enemyNearby); if (_evaluator.IsDead(enemyNearby)) { _evaluator.Eat(animal, enemyNearby); } if (_evaluator.IsDead(animal)) { continue; } } } } } else { if (animal.Diet == Diet.Herbivore) { var enemyNearby = _evaluator.FirstEnemyInLineOfSight(animal); if (enemyNearby != null) { moved = _evaluator.Flee(animal, enemyNearby, elapsed); } } // If it is in love, find a partner if (!moved && _evaluator.NeedsToReproduce(animal)) { var otherGenderAllyNearbyThatNeedsToReproduce = _evaluator.AllayInLineOfSight(animal, true); if (otherGenderAllyNearbyThatNeedsToReproduce != null) { moved = _evaluator.Approach(animal, otherGenderAllyNearbyThatNeedsToReproduce, elapsed); if (_evaluator.IsEnoughCloseToInteract(animal, otherGenderAllyNearbyThatNeedsToReproduce)) { var father = animal.Gender == Gender.Male ? animal : otherGenderAllyNearbyThatNeedsToReproduce; var mother = animal.Gender == Gender.Female ? animal : otherGenderAllyNearbyThatNeedsToReproduce; var newAnimal = _evaluator.Copulate(father: father, mother: mother); newGeneration.Add(newAnimal); if (animal.Diet == Diet.Carnivorous) { TotalBornCarnivorousNumber++; } else { TotalBornHerbivoreNumber++; } } } } if (!moved) { // Every animal tends to stay in group with his specie var allyNearby = _evaluator.AllayInLineOfSight(animal); if (allyNearby != null) { moved = _evaluator.Approach(animal, allyNearby, elapsed); } } } // Move randomly to feel alive _evaluator.RandomMove(animal, elapsed); _evaluator.EvaluateMoveEnergyCost(animal); _evaluator.EvaluateAge(animal); } for (int a = specie.Value.Count - 1; a >= 0; --a) { if (_evaluator.IsDead(specie.Value[a])) { if (specie.Value[a].Diet == Diet.Carnivorous) { TotalDeadCarnivorousNumber++; } else { TotalDeadHerbivoreNumber++; } _evaluator.Kill(specie.Value[a]); specie.Value.RemoveAt(a); } } specie.Value.AddRange(newGeneration); } for (int v = Vegetables.Count - 1; v >= 0; --v) { _evaluator.EvaluateAge(Vegetables[v]); if (Vegetables[v].IsEaten) { Vegetables.RemoveAt(v); } } if (_elapsedSinceLastVegetableGeneration > StartingValues.IntervalForVegetablesGeneration) { Vegetables.AddRange(_generator.SpawnVegetables(StartingValues.NumberOfVegetables - Vegetables.Count)); _elapsedSinceLastVegetableGeneration = TimeSpan.Zero; } if (_elapsedSinceLastDataRefreshTime > _intervalForRaiseDataRefreshTime) { DataRefresh?.Invoke(this, EventArgs.Empty); _elapsedSinceLastDataRefreshTime = TimeSpan.Zero; } }