private void ProcessInteraction() { switch (m_CollidedObject.tag) { case "VegetableDispenser": VegetableDispenserType dispenserType = m_CollidedObject.GetComponent <VegetableDispenser>().pDispenserType; if (!IsAlreadyExists(dispenserType)) { AddVegetable(dispenserType); } break; case "ChoppingBoard": ChoppingBoard choppingBoard = m_CollidedObject.GetComponent <ChoppingBoard>(); if (choppingBoard.pCurrentState == ChoppingBoardState.MAKE_SALAD) { Salad salad = choppingBoard.pSaldOnBoard; salad.transform.SetParent(this.gameObject.transform); Utilities.Util.SetDefaultLocalTransform(salad.gameObject); choppingBoard.SetState(ChoppingBoardState.CLEARED); m_SaladOnHand = salad; } else { if (m_Vegetables.Count > 0) { if (choppingBoard.CanAdd()) { Vegetable veg = m_Vegetables[0]; choppingBoard.AddVegetable(veg.pVegetableType); RemoveVegetable(veg); GameObject go = Utilities.Util.FindChildObject(gameObject, veg.name); veg.transform.SetParent(null); Destroy(go); } } } break; case "NextToChop": break; case "Salad": { } break; case "Customer": { if (m_SaladOnHand != null) { Customer customer = m_CollidedObject.GetComponent <Customer>(); Salad salad = m_SaladOnHand; customer.OnSaladServed(salad.pSaladType, this.gameObject.GetComponent <PlayerController>()); GameObject saladObj = Utilities.Util.FindChildObject(gameObject, salad.gameObject.name); saladObj.gameObject.transform.SetParent(null); Destroy(saladObj); } } break; } SetState(PlayerState.IDLE); }
private void button1_Click(object sender, EventArgs e) { if (panel1.Visible) { string json = ""; if (menuValue != "Salad" && menuValue != "Drink") { MainCourse mainCourse = new MainCourse(); mainCourse = new MainCourse(); mainCourse.Name = NameBox.Text; mainCourse.Price = Convert.ToDouble(PriceBox.Text); mainCourse.Description = DescriptionTextBox.Text; mainCourse.HouseSpecial = HouseSpecialCheckBox.Checked; json = Newtonsoft.Json.JsonConvert.SerializeObject(mainCourse); } else if (menuValue == "Salad") { salad = new Salad(); salad.Name = NameBox.Text; salad.Price = Convert.ToDouble(PriceBox.Text); salad.Description = DescriptionTextBox.Text; salad.HouseSpecial = HouseSpecialCheckBox.Checked; salad.Topping = toppingBox.Text; json = Newtonsoft.Json.JsonConvert.SerializeObject(salad); } else if (menuValue == "Drink") { drink = new Drink(); drink.Name = NameBox.Text; drink.Price = Convert.ToDouble(PriceBox.Text); drink.Description = DescriptionTextBox.Text; drink.HouseSpecial = HouseSpecialCheckBox.Checked; drink.AgeRestricted = ageRestrictedCheckbox.Checked; json = Newtonsoft.Json.JsonConvert.SerializeObject(drink); } var httpWebRequest = (HttpWebRequest)WebRequest.Create(Properties.Settings.Default.backendHostname + "/" + menuValue + "/Restaurant/edit"); httpWebRequest.Headers["Authorization"] = "Basic " + AuthValue; httpWebRequest.Headers[char.ToLower(menuValue[0]) + menuValue.Substring(1) + "Name"] = old.Name; httpWebRequest.ContentType = "text/json"; httpWebRequest.Accept = "*/*"; httpWebRequest.Method = "POST"; try { httpWebRequest.ContentLength = Encoding.ASCII.GetBytes(json).Length; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); if (httpResponse.StatusCode.ToString() == "OK") { } } catch (System.Net.WebException error) { MessageBox.Show(error.ToString()); } panel1.Hide(); MenuGrid.Show(); button1.Text = "Choose"; getJsonMenu(); } else { DataGridViewRow row = MenuGrid.CurrentRow; if (menuValue != "Salad" && menuValue != "Drink") { MainCourse mainCourse = new MainCourse(); mainCourse.Name = (string)row.Cells["Name"].Value; mainCourse.Price = (double)row.Cells["Price"].Value; mainCourse.Description = (string)row.Cells["Description"].Value; mainCourse.HouseSpecial = (bool)row.Cells["Housespecial"].Value; old = mainCourse; NameBox.Text = mainCourse.Name; PriceBox.Text = (string)mainCourse.Price.ToString(); HouseSpecialCheckBox.Checked = mainCourse.HouseSpecial; DescriptionTextBox.Text = mainCourse.Description; } else if (menuValue == "Salad") { Salad mainCourse = new Salad(); mainCourse.Name = (string)row.Cells["Name"].Value; mainCourse.Price = (double)row.Cells["Price"].Value; mainCourse.Description = (string)row.Cells["Description"].Value; mainCourse.HouseSpecial = (bool)row.Cells["Housespecial"].Value; mainCourse.Topping = (string)row.Cells["Topping"].Value; old = mainCourse; NameBox.Text = mainCourse.Name; PriceBox.Text = (string)mainCourse.Price.ToString(); HouseSpecialCheckBox.Checked = mainCourse.HouseSpecial; DescriptionTextBox.Text = mainCourse.Description; toppingBox.Text = mainCourse.Topping; } else if (menuValue == "Drink") { Drink mainCourse = new Drink(); mainCourse.Name = (string)row.Cells["Name"].Value; mainCourse.Price = (double)row.Cells["Price"].Value; mainCourse.Description = (string)row.Cells["Description"].Value; mainCourse.HouseSpecial = (bool)row.Cells["Housespecial"].Value; mainCourse.AgeRestricted = (bool)row.Cells["AgeRestricted"].Value; old = mainCourse; NameBox.Text = mainCourse.Name; PriceBox.Text = (string)mainCourse.Price.ToString(); HouseSpecialCheckBox.Checked = mainCourse.HouseSpecial; DescriptionTextBox.Text = mainCourse.Description; ageRestrictedCheckbox.Checked = mainCourse.AgeRestricted; } panel1.Show(); MenuGrid.Hide(); button1.Text = "Submit"; } }
protected SaladDecorator(string name, Salad salad) : base(name) { Salad = salad; }
public SauceDecorator(Salad salad) : base(salad) { this.Description = $"Sauce {base.Description}"; }
void Awake() { m_CustomerSalad = new Salad(); GenerateRandomSalad(); }
// GET: Food public ActionResult BuySalad(Salad salad) { return(View("FoodInfo", salad)); }
public Order(Meat meat, Bread bread, Salad salad) { this.MeatOrder = meat; this.BreadOrder = bread; this.SaladOrder = salad; }
private void SubmitButton_Click_1(object sender, EventArgs e) { var httpWebRequest = (HttpWebRequest)WebRequest.Create(Properties.Settings.Default.backendHostname + "/" + menuValue + "/Restaurant/create"); httpWebRequest.Headers["Authorization"] = "Basic " + AuthValue; httpWebRequest.ContentType = "text/json"; httpWebRequest.Accept = "*/*"; httpWebRequest.Method = "POST"; string json = ""; if (menuValue != "Salad" && menuValue != "Drink") { mainCourse = new MainCourse(); mainCourse.Name = NameBox.Text; try { mainCourse.Price = Convert.ToDouble(PriceBox.Text); if (mainCourse.Price == 0) { throw new ArgumentNullException("Invalid value"); } } catch (Exception error) { ResultLabel.Text = "Price should be number."; return; } mainCourse.Description = DescriptionTextBox.Text; mainCourse.HouseSpecial = HouseSpecialCheckBox.Checked; json = Newtonsoft.Json.JsonConvert.SerializeObject(mainCourse); } else if (menuValue == "Salad") { salad = new Salad(); salad.Name = NameBox.Text; try { salad.Price = Convert.ToDouble(PriceBox.Text); if (salad.Price == 0) { throw new ArgumentNullException("Invalid value"); } } catch (Exception error) { ResultLabel.Text = "Price should be number."; return; } salad.Description = DescriptionTextBox.Text; salad.HouseSpecial = HouseSpecialCheckBox.Checked; salad.Topping = toppingBox.Text; json = Newtonsoft.Json.JsonConvert.SerializeObject(salad); } else if (menuValue == "Drink") { drink = new Drink(); drink.Name = NameBox.Text; try { drink.Price = Convert.ToDouble(PriceBox.Text); if (drink.Price == 0) { throw new ArgumentNullException("Invalid value"); } } catch (Exception error) { ResultLabel.Text = "Price should be number."; return; } drink.Description = DescriptionTextBox.Text; drink.HouseSpecial = HouseSpecialCheckBox.Checked; drink.AgeRestricted = ageRestrictedCheckbox.Checked; json = Newtonsoft.Json.JsonConvert.SerializeObject(drink); } httpWebRequest.ContentLength = Encoding.ASCII.GetBytes(json).Length; try { using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); if (httpResponse.StatusCode.ToString() == "OK") { ResultLabel.Text = "SUCCESS!"; clearBoxes(); } } catch (System.Net.WebException error) { ResultLabel.Text = "Failed!"; } }
private void Start() { saladOnBoard = GetComponentInChildren <Salad>(); }
public SouceSalad(Salad salad) : base(salad.Name + "with souce ", salad) { }
public override int GetCost() { return(Salad.GetCost() + 10); }
public CornDecorator(Salad salad) : base(salad) { this.Description = $"Corn {base.Description}"; }
//DELETE Salad public Salad Delete(Salad salad) { _db.Execute("DELETE FROM salads WHERE id = @Id", salad); return(salad); }
private int maxVegetables = 3; // maximum vegetables in the salad // Start is called before the first frame update void Start() { requestedSalad = new Salad(); StartCoroutine(RequestSalad()); }
public ISalad CreateSalad(string name, decimal price, int calories, int quantityPerServing, int timeToPrepare, bool containsPasta) { var salad = new Salad(name, price, calories, quantityPerServing, MetricUnit.Grams, timeToPrepare, true, containsPasta); return(salad); }
private void initLevels() { Salami salami = new Salami(); Chicken chicken = new Chicken(); Salad salad = new Salad(); Tomato tomato = new Tomato(); White white = new White(); WholeGrain wholeGrain = new WholeGrain(); levels = new List <Level>() { new Level { enemyTypeAmount = new List <KeyValuePair <int, int> >() { new KeyValuePair <int, int>(Enemy.NORMAL, 12) }, maxFailsForGameOver = 2, minKillsForWin = 12, availableIngredients = new List <Ingredient>() { chicken }, spawnInterval = 3, availableBreadsWithHits = new List <KeyValuePair <Bread, int> >() { new KeyValuePair <Bread, int>(white, 20) } }, new Level { enemyTypeAmount = new List <KeyValuePair <int, int> >() { new KeyValuePair <int, int>(Enemy.VEGAN, 5), new KeyValuePair <int, int>(Enemy.NORMAL, 5), new KeyValuePair <int, int>(Enemy.VEGAN, 5), new KeyValuePair <int, int>(Enemy.NORMAL, 2) }, maxFailsForGameOver = 3, minKillsForWin = 17, availableIngredients = new List <Ingredient>() { chicken, tomato }, spawnInterval = 3, availableBreadsWithHits = new List <KeyValuePair <Bread, int> >() { new KeyValuePair <Bread, int>(white, 20) } }, new Level { enemyTypeAmount = new List <KeyValuePair <int, int> >() { new KeyValuePair <int, int>(Enemy.NORMAL, 5), new KeyValuePair <int, int>(Enemy.VEGAN, 5), new KeyValuePair <int, int>(Enemy.FAT, 1), new KeyValuePair <int, int>(Enemy.NORMAL, 5), new KeyValuePair <int, int>(Enemy.FAT, 1), new KeyValuePair <int, int>(Enemy.VEGAN, 5) }, maxFailsForGameOver = 4, minKillsForWin = 22, availableIngredients = new List <Ingredient>() { chicken, tomato, salad, salami }, spawnInterval = 3, availableBreadsWithHits = new List <KeyValuePair <Bread, int> >() { new KeyValuePair <Bread, int>(white, 20), new KeyValuePair <Bread, int>(wholeGrain, 30) } }, new Level { enemyTypeAmount = new List <KeyValuePair <int, int> >() { new KeyValuePair <int, int>(Enemy.NORMAL, 8), new KeyValuePair <int, int>(Enemy.VEGAN, 7), new KeyValuePair <int, int>(Enemy.FAT, 7) }, maxFailsForGameOver = 6, minKillsForWin = 22, availableIngredients = new List <Ingredient>() { chicken, tomato, salad, salami }, spawnInterval = 2, availableBreadsWithHits = new List <KeyValuePair <Bread, int> >() { new KeyValuePair <Bread, int>(white, 20), new KeyValuePair <Bread, int>(wholeGrain, 30) } }, new Level { enemyTypeAmount = new List <KeyValuePair <int, int> >() { new KeyValuePair <int, int>(Enemy.NORMAL, 8), new KeyValuePair <int, int>(Enemy.VEGAN, 8), new KeyValuePair <int, int>(Enemy.FAT, 9) }, maxFailsForGameOver = 6, minKillsForWin = 25, availableIngredients = new List <Ingredient>() { chicken, tomato, salad, salami }, spawnInterval = 1, availableBreadsWithHits = new List <KeyValuePair <Bread, int> >() { new KeyValuePair <Bread, int>(white, 20), new KeyValuePair <Bread, int>(wholeGrain, 30) } } }; /* levels = new List<Level>(){ * new Level { * enemyTypeAmount = new List<KeyValuePair<int, int>>() { * new KeyValuePair<int, int>(Enemy.NORMAL, 10) * }, * maxFailsForGameOver = 1, * minKillsForWin = 10, * availableIngredients = new List<Ingredient>() {chicken}, * spawnInterval = 3, * availableBreadsWithHits = new List<KeyValuePair<Bread, int>>() { * new KeyValuePair<Bread, int>(white, 30) * } * }, * new Level { * enemyTypeAmount = new List<KeyValuePair<int, int>>() { * new KeyValuePair<int, int>(Enemy.VEGAN, 5), * new KeyValuePair<int, int>(Enemy.NORMAL, 5), * new KeyValuePair<int, int>(Enemy.VEGAN, 5), * new KeyValuePair<int, int>(Enemy.NORMAL, 5) * }, * maxFailsForGameOver = 1, * minKillsForWin = 20, * availableIngredients = new List<Ingredient>() {chicken, tomato}, * spawnInterval = 3, * availableBreadsWithHits = new List<KeyValuePair<Bread, int>>() { * new KeyValuePair<Bread, int>(white, 30), * new KeyValuePair<Bread, int>(wholeGrain, 20) * } * }, * new Level { * enemyTypeAmount = new List<KeyValuePair<int, int>>() { * new KeyValuePair<int, int>(Enemy.NORMAL, 5), * new KeyValuePair<int, int>(Enemy.VEGAN, 5), * new KeyValuePair<int, int>(Enemy.FAT, 1), * new KeyValuePair<int, int>(Enemy.NORMAL, 5), * new KeyValuePair<int, int>(Enemy.FAT, 1), * new KeyValuePair<int, int>(Enemy.VEGAN, 5) * }, * maxFailsForGameOver = 1, * minKillsForWin = 22, * availableIngredients = new List<Ingredient>() {chicken, tomato, salad, salami}, * spawnInterval = 1, * availableBreadsWithHits = new List<KeyValuePair<Bread, int>>() { * new KeyValuePair<Bread, int>(white, 30), * new KeyValuePair<Bread, int>(wholeGrain, 20) * } * } * };*/ }
void Start() { m_SpriteRenderer = GetComponent <SpriteRenderer>(); m_FreezeCuttingBoard = false; m_CuttingBoardSalad = new Salad(); }
public override double ComputeCost() { return(3.0 + Salad.ComputeCost()); }
static void Main(string[] args) { Calories cl = new Calories(2, 3, 4); Calories c2 = 2*cl; var potato = new Potato(100); var cucmber = new Cucumber(100); var carrot = new Carrot(200); var cust = new CustomVegetable("1", 2, new Calories()); Console.WriteLine(cust); cust.Weight = 3; cust.Calories = new Calories(); cust.Name = "13"; Console.WriteLine(cust); Console.WriteLine(potato.Name + " " + potato.Calories + " " + potato.Weight); Console.WriteLine(cucmber.Name + " " + cucmber.Calories + " " + cucmber.Weight); Console.WriteLine(carrot.Name + " " + carrot.Calories + " " + carrot.Weight); List<IVegetable> lst = new List<IVegetable>(); lst.Add(cucmber); Salad salad = new Salad(new CloneList<IVegetable>()); salad.Add(potato); salad.Add(carrot); salad.Add(cucmber); Console.WriteLine("total calories = " + salad.TotalCalories); Console.WriteLine(); Console.WriteLine(); salad.PrintVegetables(); var tt = salad.GetVegetables(0, 1000); Console.WriteLine(); Console.WriteLine(); salad.PrintVegetables(); salad.Sort(VegetableComparasions.CompareByName); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("BEFORE SRT"); salad.PrintVegetables(); salad.Sort(vegetable => vegetable.Calories, new CompareByCalories()); Func<int, int> d = delegate(int i) { return i*3; }; Console.WriteLine("AFTER SRT"); salad.PrintVegetables(); salad.Sort(VegetableComparasions.CompareByWeight); Console.WriteLine("BEFORE REMOVE"); salad.PrintVegetables(); salad.Remove(potato); Console.WriteLine("AFTER REMOVE"); salad.PrintVegetables(); Console.WriteLine("TESTTTT"); CloneList<IVegetable> list = new CloneList<IVegetable>(); List<int> li = new List<int>(); list.Add(potato); list.Add(cucmber); list.Add(carrot); foreach (var v in list) { Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight); } Console.WriteLine("CLONE"); ICloneCollection<IVegetable> list2 = list.CloneObjects(); foreach (var v in list2) { Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight); } list[0].Weight = 0; list[1].Weight = 0; list[2].Weight = 0; Console.WriteLine("TESTTTT"); foreach (var v in list) { Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight); } Console.WriteLine("CLONE"); foreach (var v in list2) { Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight); } }
public void addSalad(Salad salad) { salads.Add(salad); }