Beispiel #1
0
        static void Main(string[] args)
        {
            var liquids = new List <ILiquid>()
            {
                new Liquid("Water"), new Liquid("Fuel")
            };
            var liquidProvider = new LiquidProvider(liquids);

            var energies = new List <IEnergy>()
            {
                new Energy("Electricity"), new Energy("SomethingElse")
            };
            var energyProvider = new EnergyProvider(energies);

            var regularKettle  = new RegularKettle();
            var electricKettle = new ElectricKettle();

            var capacity = new CapacityUnit(100);
            var utensil  = new Utensil("Kettle", capacity);
            var boiler   = new Boiler("Кипятильник");

            regularKettle.Utensil = utensil;
            regularKettle.Boiler  = boiler;
            regularKettle.WorksOn = energies;

            electricKettle.Utensil = utensil;
            electricKettle.Boiler  = boiler;
            electricKettle.WorksOn = energies;

            var regularKettleRunner  = new Runner.Runner(liquidProvider, energyProvider, regularKettle);
            var electricKettleRunner = new Runner.Runner(liquidProvider, energyProvider, electricKettle);
        }
Beispiel #2
0
        private void GenerateTestData()
        {
            Ingredient Apple    = new Ingredient(0, "Whole Apples", 1.5, Unit.Self);
            Ingredient Sugar    = new Ingredient(1, "Sugar", 1, Unit.Cup);
            Ingredient Cinnamon = new Ingredient(2, "Cinnamon", 2, Unit.Tbs);
            Ingredient Salt     = new Ingredient(3, "Salt", .5, Unit.tsp);

            Utensil whisk = new Utensil(0, "Whisk", "Whisk it");
            Utensil bowl  = new Utensil(1, "Bowl", "Stir in it");

            List <Ingredient> ingredientsAC = new List <Ingredient> {
                Apple, Sugar, Cinnamon, Salt
            };
            List <Utensil> utensils = new List <Utensil> {
                whisk, bowl
            };

            this.appleCrisp = new Recipe(0, "Apple Crisp", ingredientsAC, utensils, 350,
                                         "Whisk it all in a bowl", false);

            Ingredient        butter        = new Ingredient(0, "Butter", 1.5, Unit.Cup);
            Ingredient        sugar         = new Ingredient(1, "Sugar", 1, Unit.Cup);
            Ingredient        chocolate     = new Ingredient(2, "Chocolate", 2, Unit.Tbs);
            Ingredient        salt          = new Ingredient(3, "Salt", .5, Unit.tsp);
            List <Ingredient> ingredientsCC = new List <Ingredient>(new Ingredient[] { butter, sugar, chocolate, salt });


            this.chocolateCake = new Recipe(1, "Chocolate Cake", ingredientsCC, new List <Utensil>(), 170, "Whisk it all in a bowl", true);
        }
Beispiel #3
0
        public override void SetProperties(Utensil utensil, List <string> values)
        {
            base.SetProperties(utensil as Cup, values);

            (utensil as Cup).HaftCount = int.Parse(values[3]);
            utensil.Name = "Кружка";
        }
Beispiel #4
0
        public override List <string> GetProperties(Utensil utensil)
        {
            var values = base.GetProperties(utensil);

            values.Add((utensil as Cup).HaftCount.ToString());

            return(values);
        }
Beispiel #5
0
        public override List <string> GetProperties(Utensil utensil)
        {
            var values = base.GetProperties(utensil);

            values.Add((utensil as Steamer).Capasity.ToString());
            values.Add((utensil as Steamer).ContainersCout.ToString());

            return(values);
        }
Beispiel #6
0
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            Utensil temp = mainList[listBoxItems.SelectedIndex];

            mainList.Remove(temp);
            flag = false;
            listBoxItems.Items.RemoveAt(listBoxItems.SelectedIndex);
            ClearValues();
        }
Beispiel #7
0
        public override void SetProperties(Utensil utensil, List <string> values)
        {
            base.SetProperties(utensil as Tureen, values);

            (utensil as Tureen).HaftCount = int.Parse(values[3]);
            (utensil as Tureen).Shape     = values[4];

            utensil.Name = "Супница";
        }
Beispiel #8
0
        public override List <string> GetProperties(Utensil utensil)
        {
            var values = base.GetProperties(utensil);

            values.Add((utensil as Pan).Diameter.ToString());
            values.Add((utensil as Pan).CoverType);

            return(values);
        }
Beispiel #9
0
        public override void SetProperties(Utensil utensil, List <string> values)
        {
            base.SetProperties(utensil as Pan, values);


            (utensil as Pan).Diameter  = Int32.Parse(values[3]);
            (utensil as Pan).CoverType = values[4];

            utensil.Name = "Сковорода";
        }
Beispiel #10
0
        public virtual List <string> GetProperties(Utensil utensil)
        {
            var values = new List <string>();

            values.Add(utensil.Color);
            values.Add(utensil.Material);
            values.Add(utensil.Fabricator);

            return(values);
        }
Beispiel #11
0
        public override void SetProperties(Utensil utensil, List <string> values)
        {
            base.SetProperties(utensil as Steamer, values);


            (utensil as Steamer).Capasity       = int.Parse(values[5]);
            (utensil as Steamer).ContainersCout = int.Parse(values[6]);

            utensil.Name = "Пароварка";
        }
Beispiel #12
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Utensil = await _context.Utensil.FirstOrDefaultAsync(m => m.UtensilID == id);

            if (Utensil == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #13
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (CheckEmptyTextBoxes())
     {
         var values = GetPropertyValues();
         utensil = creators[resultType].CreateUtensil(values);
         mainList.Add(utensil);
         listBoxItems.Items.Add(utensil.Name);
         ClearValues();
     }
     else
     {
         MessageBox.Show("Не все поля заполнены!");
     }
 }
        public static Recipe ChocolateCake()
        {
            Ingredient        butter      = new Ingredient(0, "Butter", 1.5, Unit.Cup);
            Ingredient        sugar       = new Ingredient(1, "Sugar", 1, Unit.Cup);
            Ingredient        chocolate   = new Ingredient(2, "Chocolate", 2, Unit.Tbs);
            Ingredient        salt        = new Ingredient(3, "Salt", .5, Unit.tsp);
            List <Ingredient> ingredients = new List <Ingredient>(new Ingredient[] { butter, sugar, chocolate, salt });

            Utensil        whisk    = new Utensil(0, "Whisk", "Whisk it");
            Utensil        bowl     = new Utensil(1, "Bowl", "Stir in it");
            List <Utensil> utensils = new List <Utensil>(new Utensil[] { whisk, bowl });

            Recipe chocolateCake = new Recipe(0, "Chocolate Cake", ingredients, utensils, 350, "Whisk it all in a bowl", false);

            return(chocolateCake);
        }
Beispiel #15
0
 public void BuyUtensil(Utensil utensil)
 {
     if (BakingProwess > utensil.Cost)
     {
         MyUtensils.Add(utensil);
         BakingProwess -= utensil.Cost;
         BakingBoost   += utensil.Boost;
         System.Console.Clear();
         System.Console.WriteLine($"You bought the {utensil.name} with {utensil.Cost} Baking Prowess! Your BakingBoost is now {BakingBoost}!");
     }
     else
     {
         System.Console.Clear();
         System.Console.WriteLine($"You are too poor to buy that item. Why don't you go beg on the street, you loser? Your prowess is now {BakingProwess}");
     }
 }
Beispiel #16
0
        static void Main()
        {
            Ingredient        apple       = new Ingredient(0, "Whole Apples", 1.5, Unit.Self);
            Ingredient        sugar       = new Ingredient(1, "Sugar", 1, Unit.Cup);
            Ingredient        cinnamon    = new Ingredient(2, "Cinnamon", 2, Unit.Tbs);
            Ingredient        salt        = new Ingredient(3, "Salt", .5, Unit.tsp);
            List <Ingredient> ingredients = new List <Ingredient>(new Ingredient[] { apple, sugar, cinnamon, salt });

            Utensil        whisk    = new Utensil(0, "Whisk", "Whisk it");
            Utensil        bowl     = new Utensil(1, "Bowl", "Stir in it");
            List <Utensil> utensils = new List <Utensil>(new Utensil[] { whisk, bowl });

            Recipe appleCrisp = new Recipe(0, "Apple Crisp", ingredients, utensils, 350, "Whisk it all in a bowl", false);

            Console.WriteLine(appleCrisp.ToString());
        }
Beispiel #17
0
 public override bool AddItem(GameObject obj)
 {
     if (obj.GetComponent <Utensil>())
     {
         Utensil utensil = obj.GetComponent <Utensil>();
         for (int i = 0; i < utensil.current_food_items.Count; i++)
         {
             utensil.current_food_items.RemoveAt(i);
         }
         foreach (Transform child in obj.transform)
         {
             Destroy(child.gameObject);
         }
     }
     else
     {
         Destroy(obj);
     }
     return(false);
 }
Beispiel #18
0
 public bool CheckAddedItem(Utensil item)
 {
     for (int i = 0; i < goal_list.Count; i++)
     {
         if (item.type == goal_list[i].type)
         {
             if (item.current_food_items.Count == goal_list[i].current_food_items.Count)
             {
                 for (int y = 0; y < goal_list[i].current_food_items.Count; y++)
                 {
                     if (item.current_food_items[y].type != goal_list[i].current_food_items[y].type)
                     {
                         return(false);
                     }
                 }
                 gameObject.GetComponent <ScoreManager>().addScore[i] = true;
                 return(true);
             }
         }
     }
     return(false);
 }
    public bool CheckItem(GameObject obj)
    {
        if (obj.GetComponent <Utensil>())
        {
            Utensil utensil = obj.GetComponent <Utensil>();

            switch (utensil.type)
            {
            case UtensilType.Pan:
            case UtensilType.Pot:
                return(false);

            case UtensilType.Plate:
                if (utensil.current_food_items.Count > 0)
                {
                    current_item = obj;
                    return(true);
                }
                return(false);
            }
        }
        return(false);
    }
Beispiel #20
0
    public bool FoodToUtenstil(GameObject food_obj, GameObject utensil_obj)
    {
        FoodItem food    = food_obj.GetComponent <FoodItem>();
        Utensil  utensil = utensil_obj.GetComponent <Utensil>();

        if (utensil.allowed_foods[(int)food.type].allowed == true)
        {
            if (utensil.type == UtensilType.Plate)
            {
                if (food.prepared == true)
                {
                    if (utensil.AddFood(food))
                    {
                        return(true);
                    }
                }
            }
            else if (utensil.type == UtensilType.Pan)
            {
                if (utensil.AddFood(food))
                {
                    return(true);
                }
            }
            else if (utensil.type == UtensilType.Pot)
            {
                if (food.prepared == true)
                {
                    if (utensil.AddFood(food))
                    {
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Beispiel #21
0
    public bool UtensilToUtensil(GameObject pickup_obj, GameObject surface_obj)
    {
        Utensil utensil_pickup  = pickup_obj.GetComponent <Utensil>();
        Utensil utensil_surface = surface_obj.GetComponent <Utensil>();

        if (utensil_surface.type == UtensilType.Plate)
        {
            for (int i = 0; i < utensil_pickup.current_food_items.Count; i++)
            {
                if (!utensil_pickup.current_food_items[i].cooked || utensil_pickup.current_food_items[i].burnt)
                {
                    return(false);
                }
                else
                {
                    utensil_surface.AddFood(utensil_pickup.current_food_items[i]);
                    utensil_pickup.current_food_items.RemoveAt(i);
                }
            }
            utensil_pickup.ResetCookValues();
            return(false);
        }
        return(false);
    }
Beispiel #22
0
 public UtensilType GetUtensilType(Utensil utensil)
 {
     return(utensil.type);
 }
        public IActionResult OnPostCreateRecipe()
        {
            TryUpdateModelAsync(this);

            // retorna erros se os campos foram incorretamente preenchidos ou não preenchidos
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            User us  = dbContext.User.FirstOrDefault(u => u.Email.Equals(User.Identity.Name));
            var  now = DateTime.Now;

            DateTime date = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0);
            // cria o cliente
            Recipe newRecipe = new Recipe()
            {
                Title           = Recipe.Title,
                Description     = Recipe.Description,
                Rank            = 0,
                Classifications = 0,
                Time            = 0,
                Date            = date,
                Price           = Recipe.Price,
                ImgRecipe       = getImage(ImgRecipe).ToArray(),
                UserID          = us.UserID
            };

            // adiciona a receita à BD
            dbContext.Recipe.Add(newRecipe);

            foreach (Tag t in Tags)
            {
                Tag newTag = new Tag()
                {
                    Name = t.Name
                };
                dbContext.Tag.Add(newTag);

                RecipeTag rt = new RecipeTag()
                {
                    RecipeID = newRecipe.RecipeID,
                    TagID    = newTag.TagID,
                };

                dbContext.RecipeTag.Add(rt);
            }

            foreach (Ingredient i in Ingredientes)
            {
                Ingredient newIng = new Ingredient()
                {
                    Name = i.Name
                };
                dbContext.Ingredient.Add(newIng);

                RecipeIngredient ri = new RecipeIngredient()
                {
                    RecipeID     = newRecipe.RecipeID,
                    IngredientID = newIng.IngredientID,
                };
                dbContext.RecipeIngredient.Add(ri);
            }

            foreach (Utensil u in Utensils)
            {
                Utensil newUten = new Utensil()
                {
                    Name = u.Name
                };
                dbContext.Utensil.Add(newUten);

                RecipeUtensils ru = new RecipeUtensils()
                {
                    RecipeID  = newRecipe.RecipeID,
                    UtensilID = newUten.UtensilID,
                };
                dbContext.RecipeUtensils.Add(ru);
            }

            // guarda as alterações
            dbContext.SaveChanges();
            var rid = newRecipe.RecipeID;

            return(RedirectToPage("./RecipeAddStep", "GetRecipe", new { Recipeid = rid, StepPos = 1 }).WithSuccess("Sucesso", "Receita criada com sucesso, adicionar passos", "3000"));
        }
Beispiel #24
0
        protected override void DrawInternal()
        {
            GUIControlHandle handle = GUIExtensions.GetControlHandle(FocusType.Passive);

            Texture2D  texture            = this.GetContents <Texture2D>();
            Vector3    position           = this.GetAuxContents <Vector3>("position");
            Quaternion rotation           = this.GetAuxContents <Quaternion>("rotation");
            Vector2    size               = this.GetAuxContents <Vector2>("size");
            bool       is_overlay_enabled = this.GetAuxContents <bool>("is_overlay_enabled");

            Surface <Color> surface = texture.GetSurface();
            Utensil <Color> utensil = Painter.GetInstance().GetUtensil();

            Matrix4x4 transform     = Matrix4x4.TRS(position, rotation, size.GetSpacar(1.0f));
            Matrix4x4 inv_transform = transform.inverse;

            Vector3 world_point = Camera.current.ScreenToWorldPlanePoint(
                transform.MultiplyPlane(PlaneExtensions.CreateNormalAndPoint(new Vector3(0.0f, 0.0f, 1.0f), Vector3.zero)),
                handle.GetEvent().mousePosition.ConvertFromGUIToScreen()
                );

            Vector3 local_point   = inv_transform.MultiplyPoint(world_point);
            Vector2 texture_point = local_point.GetComponentMultiply(texture.GetSize()).GetPlanar() + 0.5f * texture.GetSize();

            Vector3 brush_size = new Vector2(Painter.GetInstance().GetBrushSize(), Painter.GetInstance().GetBrushSize())
                                 .GetComponentDivide(texture.GetSize())
                                 .GetComponentMultiply(size)
                                 .GetSpacar(1.0f);

            if (handle.IsControlCaptured() && is_overlay_enabled)
            {
                surface_now_mesh.GetMaterial().SetMainTexture(texture);
                surface_now_mesh.Draw(transform);
            }

            brush_now_mesh.Draw(world_point, rotation, brush_size);

            if (handle.GetEventType().IsMouseRelated() && handle.GetEvent().button == 0)
            {
                if (handle.GetEventType() == EventType.MouseDown)
                {
                    handle.CaptureControl();

                    this.Execute("MouseDown");
                    last_texture_point = texture_point;
                }

                if (handle.GetEventType() == EventType.MouseUp)
                {
                    handle.ReleaseControl();

                    this.Execute("MouseUp");
                }

                if (handle.IsControlCaptured())
                {
                    line_tool.MarkLines(surface, utensil, last_texture_point.GetVectorF2(), texture_point.GetVectorF2());
                    texture.Apply();
                }

                last_texture_point = texture_point;
                handle.UseEvent();
            }
        }
Beispiel #25
0
 public virtual void SetProperties(Utensil utensil, List <string> values)
 {
     utensil.Color      = values[0];
     utensil.Material   = values[1];
     utensil.Fabricator = values[2];
 }
    public void CookItems()
    {
        if (current_item)
        {
            if (current_item.GetComponent <Utensil>())
            {
                Utensil current_utensil = current_item.GetComponent <Utensil>();

                if (current_utensil.current_food_items.Count > 0)
                {
                    progress_bar.gameObject.SetActive(true);
                    //start cooking if food is in the utensil
                    current_utensil.current_cooking_time += 1 * Time.deltaTime;
                    progress_bar.CalculateProgress(current_utensil.current_cooking_time, current_utensil.cook_time);

                    if (current_utensil.current_cooking_time >= current_utensil.cook_time)
                    {
                        for (int i = 0; i < current_utensil.current_food_items.Count; i++)
                        {
                            current_utensil.current_food_items[i].cooked = true;
                            current_utensil.current_food_items[i].GetComponent <SpriteRenderer>().sprite = current_utensil.current_food_items[i].preped_sprite;
                        }
                    }
                    if (current_utensil.current_cooking_time > current_utensil.cook_time + 2)
                    {
                        progress_bar.gameObject.SetActive(false);
                    }

                    if (current_utensil.current_cooking_time >= current_utensil.burnt_timer)
                    {
                        for (int i = 0; i < current_utensil.current_food_items.Count; i++)
                        {
                            current_utensil.current_food_items[i].burnt = true;
                            current_utensil.current_food_items[i].GetComponent <SpriteRenderer>().color = Color.black;
                            if (!fire_made)
                            {
                                GameObject new_fire = Instantiate(fire_prefab, transform.position, transform.rotation) as GameObject;
                                new_fire.name             = "Fire";
                                new_fire.transform.parent = transform;
                                new_fire.GetComponent <FireScript>().fire_timer = 0.0f;
                                fire      = new_fire;
                                fire_made = true;
                            }
                        }
                    }
                    else
                    {
                        fire_made = false;
                    }
                }
                else
                {
                    progress_bar.gameObject.SetActive(false);
                }
            }
        }
        else
        {
            progress_bar.gameObject.SetActive(false);
        }
    }