Esempio n. 1
0
 public void clear()
 {
     currentDish.Clear();
     GetComponent <Image>().sprite = defaultImg;
     timer.GetComponent <Timer>().ClearTime();
     dish = Menu.Dish.Wrong;
 }
Esempio n. 2
0
 public void OnEnable()
 {
     GetComponent <Image>().sprite = defaultImg;
     myMenu      = Menu.getMenu(cookerMenu);
     currentDish = new HashSet <Menu.Ingredient>();
     timer       = this.gameObject.transform.GetChild(0).gameObject;
     dish        = Menu.Dish.Wrong;
 }
Esempio n. 3
0
    public Sprite getSprite(Menu.Dish dish)
    {
        switch (dish)
        {
        case Menu.Dish.TomatoBeef:
            return(TomatoBeef.GetComponent <SpriteRenderer>().sprite);

            break;

        case Menu.Dish.PepperBean:
            return(PepperBean.GetComponent <SpriteRenderer>().sprite);

            break;

        case Menu.Dish.Bun:
            return(Bun.GetComponent <SpriteRenderer>().sprite);

        case Menu.Dish.Dumpling:
            return(Dumpling.GetComponent <SpriteRenderer>().sprite);
        }
        return(null);
    }
Esempio n. 4
0
    public void OnDrop(PointerEventData data)
    {
        if (receivingImage == null)
        {
            return;
        }

        //get ingredient this time
        var originalObj = data.pointerDrag;

        if (originalObj == null)
        {
            return;
        }
        var dragMe = originalObj.GetComponent <DragMe>();

        if (dragMe == null)
        {
            return;
        }
        var thisIngredient = dragMe.type;

        currentDish.Add(thisIngredient);

        //check if it is in menu, m is Menu.Dish
        bool accept = false;

        HashSet <Menu.Ingredient> book;

        foreach (var m in myMenu)
        {
            book = Menu.getCookBook(m);
            if (book == null)
            {
                continue;
            }
            if (book.SetEquals(currentDish))
            {
                GetComponent <Image>().sprite = GetComponent <DishImage>().getSprite(m);
                timer.GetComponent <Timer>().RunTime();
                dish = m;
                return;
            }
            if (book.Contains(thisIngredient))
            {
                accept = true;
            }
        }
        if (!accept)
        {
            currentDish.Remove(thisIngredient);
            return;
        }


        if (isWrong())
        {
            GetComponent <Image>().sprite = GetComponent <DishImage>().Wrong.GetComponent <SpriteRenderer>().sprite;
            return;
        }

        Sprite dropSprite = GetDropSprite(data);

        if (dropSprite != null)
        {
            receivingImage.sprite = dropSprite;
        }
    }
Esempio n. 5
0
 public void setDish(Menu.Dish d)
 {
     dish = d;
 }
Esempio n. 6
0
        private void del_dish_btn_Click(object sender, EventArgs e)
        {
            Dish dd = (Dish)all_dish_list.SelectedItem;

            DelDish(dd);
        }
Esempio n. 7
0
        public GramForm(Dish d)
        {
            InitializeComponent();

            this.Dish = d;
        }
Esempio n. 8
0
        private void add_aft_dish_btn_Click(object sender, EventArgs e)
        {
            Dish obj = (Dish)all_dish_list.SelectedItem;

            if (obj == null)
            {
                MessageBox.Show("Выберите блюдо из списка!");
            }
            else if (obj.MealTime.ToLower() != "полдник")
            {
                MessageBox.Show("Это блюдо нельзя добавить в полдник!");
            }
            else
            {
                DishGram dishGram = new DishGram();
                using (var f = new GramForm(obj))
                {
                    f.Owner = this;
                    var res = f.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        double num = f.gram;
                        dishGram.d     = obj;
                        dishGram.gramm = num;
                        dg.Add(dishGram);

                        car      += obj.Carbohydrates * (num / 100);
                        fat      += obj.Fats * (num / 100);
                        prot     += obj.Protein * (num / 100);
                        aft_norm += obj.Calories * (num / 100);
                        sum      += obj.Calories * (num / 100);

                        if (Convert.ToDouble(aft_day_kal_lbl.Text) < aft_norm)
                        {
                            car        -= obj.Carbohydrates * (num / 100);
                            fat        -= obj.Fats * (num / 100);
                            prot       -= obj.Protein * (num / 100);
                            break_norm -= obj.Calories * (num / 100);
                            sum        -= obj.Calories * (num / 100);

                            MessageBox.Show("Вы превысили калорий!!!");
                        }

                        else if (Convert.ToDouble(norm_carbohydrates_lbl.Text) < car)
                        {
                            car        -= obj.Carbohydrates * (num / 100);
                            fat        -= obj.Fats * (num / 100);
                            prot       -= obj.Protein * (num / 100);
                            break_norm -= obj.Calories * (num / 100);
                            sum        -= obj.Calories * (num / 100);

                            MessageBox.Show("Вы превысили норму углеводов!!!");
                        }

                        else if (Convert.ToDouble(norm_fats_lbl.Text) < fat)
                        {
                            car        -= obj.Carbohydrates * (num / 100);
                            fat        -= obj.Fats * (num / 100);
                            prot       -= obj.Protein * (num / 100);
                            break_norm -= obj.Calories * (num / 100);
                            sum        -= obj.Calories * (num / 100);

                            MessageBox.Show("Вы превысили норму жиров!!!");
                        }

                        else if (Convert.ToDouble(norm_proteins_lbl.Text) < prot)
                        {
                            car        -= obj.Carbohydrates * (num / 100);
                            fat        -= obj.Fats * (num / 100);
                            prot       -= obj.Protein * (num / 100);
                            break_norm -= obj.Calories * (num / 100);
                            sum        -= obj.Calories * (num / 100);

                            MessageBox.Show("Вы превысили норму белков!!!");
                        }

                        else
                        {
                            typed_carbohydrates_lbl.Text = car.ToString();
                            typed_fats_lbl.Text          = fat.ToString();
                            typed_proteins_lbl.Text      = prot.ToString();

                            aft_dish_list.Items.Add(dishGram);

                            rec_aft_kal_lbl.Text = aft_norm.ToString();
                        }

                        earn_day_kal_lbl.Text = sum.ToString();
                    }
                }
            }
        }