public async Task <IActionResult> Edit(int id, [Bind("RecipeID,RecipeName,PrepTime,RecipeBy,Extension,Ingredients,RecipeDetail,CategoryID")] FoodRecipe foodRecipe)
        {
            if (id != foodRecipe.RecipeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(foodRecipe);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FoodRecipeExists(foodRecipe.RecipeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.FoodCategories, "CategoryID", "CategoryName", foodRecipe.CategoryID);
            return(View(foodRecipe));
        }
Beispiel #2
0
        private async void RecipeGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            FoodRecipe fr = e.ClickedItem as FoodRecipe;

            var contentDialog = new ContentDialog()
            {
                Content           = new FoodRecipeDialog(fr),
                PrimaryButtonText = "确定",
                FullSizeDesired   = false
            };

            contentDialog.Style = transparent;

            contentDialog.Closed += async(_s, _e) =>
            {
                await FoodGrid.Blur(value : 0, duration : 0, delay : 0).StartAsync();

                contentDialog.Hide();
            };

            contentDialog.PrimaryButtonClick += async(_s, _e) =>
            {
                await FoodGrid.Blur(value : 0, duration : 0, delay : 0).StartAsync();

                contentDialog.Hide();
            };
            await FoodGrid.Blur(value : 7, duration : 100, delay : 0).StartAsync();

            await contentDialog.ShowAsync();
        }
 void DestroyUsedObjects(FoodRecipe fr)
 {
     for (int i = 0; i < objectInside.Count; i++) //Destroy
     {
         if (fr.recipeID.Contains(objectInside[i].gameObject.GetComponent <Food>().foodID))
         {
             Destroy(objectInside[i].gameObject);
         }
     }
 }
Beispiel #4
0
        private FoodRecipe GetMappingToFoodRecipe(RecipeRequest recipeRequest)
        {
            var recipe = new FoodRecipe
            {
                FoodName    = recipeRequest.FoodName,
                PrepTime    = recipeRequest.PrepTime,
                ReadyIn     = recipeRequest.ReadyIn,
                CookingTime = recipeRequest.CookingTime,
                CreatedBy   = recipeRequest.CreatedBy
            };

            return(recipe);
        }
        public FoodRecipe GetMappingToFoodRecipe(RecipeRequest recipeRequest)
        {
            var recipe = new FoodRecipe
            {
                FoodName    = recipeRequest.FoodName,
                PrepTime    = recipeRequest.PrepTime,
                ReadyIn     = recipeRequest.ReadyIn,
                CookingTime = recipeRequest.CookingTime,
                CreatedBy   = recipeRequest.CreatedBy,
                CreatedOn   = DateTime.Now
            };

            return(recipe);
        }
    // Use this for initialization
    void Start()
    {
        gameScript = FindObjectOfType <GameController>().gameObject.GetComponent <GameController>();
        Transform[] children = new Transform[references.childCount];
        for (int i = 0; i < references.childCount; i++)
        {
            children[i] = references.GetChild(i);
        }

        foreach (Transform child in children)
        {
            FoodRecipe foodRep = new FoodRecipe(child.GetComponent <ComplexFood>().recipeID, child.gameObject);
            foodRecipes.Add(foodRep);
        }
    }
    IEnumerator Combining(FoodRecipe fr)
    {
        combining           = true;
        doorScript.isLocked = true;
        textComp.text       = "Combining...";
        yield return(new WaitForSeconds(15));

        doorScript.isLocked = false;
        GameObject spawnee = Instantiate(fr.foodObject, spawnPos.position, Quaternion.identity);

        spawnee.transform.SetParent(spawnPos);
        textComp.text = fr.foodObject.name;
        DestroyUsedObjects(fr);
        combining        = false;
        audioScript.loop = false;
        audioScript.PlayOneShot(sound[1]);
    }
Beispiel #8
0
        public Response Post(string id, [FromBody] FoodRecipe value)
        {
            Response r = new Response();

            if (value == null)
            {
                r.Success = false;
                r.Message = "Null Recipe Found";
                return(r);
            }

            value = GlobalFunctions.AddIdIfNeeded(value, id);
            accessor.Post(value);

            r.Message = value.idString;

            return(r);
        }
Beispiel #9
0
        public FoodRecipeDialog(FoodRecipe fr)
        {
            this.InitializeComponent();

            RecipeImage.Source      = new BitmapImage(new Uri(fr.Image));
            RecipeName.Text         = fr.Name;
            RecipeEnName.Text       = fr.EnName;
            RecipeNeed.Text         = fr.Need;
            Hunger.Values           = new ChartValues <double>(new double[] { fr.Hunger });
            Health.Values           = new ChartValues <double>(new double[] { fr.Health });
            Sanity.Values           = new ChartValues <double>(new double[] { fr.Sanity });
            Cooktime.Values         = new ChartValues <double>(new double[] { fr.Cooktime });
            Perish.Values           = new ChartValues <double>(new double[] { fr.Perish });
            Recommend1.Source       = new BitmapImage(new Uri(fr.Recommend1));
            Recommend2.Source       = new BitmapImage(new Uri(fr.Recommend2));
            Recommend3.Source       = new BitmapImage(new Uri(fr.Recommend3));
            Recommend4.Source       = new BitmapImage(new Uri(fr.Recommend4));
            RecipeIntroduction.Text = fr.Introduction;
            Console.Text            = fr.Console;
        }
Beispiel #10
0
    public FoodRecipe MakeRecipe(List <FoodIngredient> ingredients)
    {
        ingredients.Sort();

        int key = 0;

        for (int i = 0; i < ingredients.Count; i++)
        {
            key *= 10;
            key += ingredients[i].id;
        }

        FoodRecipe recipe = null;

        if (recipeDictionary.ContainsKey(key))
        {
            recipe = recipeDictionary[key];
        }
        return(recipe);
    }
        public async Task <IActionResult> Create([Bind("RecipeID,RecipeName,PrepTime,RecipeBy,File,Ingredients,RecipeDetail,CategoryID")] FoodRecipe foodRecipe)
        {
            using (var memoryStream = new MemoryStream())
            {
                await foodRecipe.File.FormFile.CopyToAsync(memoryStream);

                string photoname = foodRecipe.File.FormFile.FileName;
                foodRecipe.Extension = Path.GetExtension(photoname);
                if (!".jpg.jpeg.png.gif.bmp".Contains(foodRecipe.Extension.ToLower()))
                {
                    ModelState.AddModelError("File.FormFile", "Invalid Format of Image Given.");
                }
                else
                {
                    ModelState.Remove("Extension");
                }
            }
            if (ModelState.IsValid)
            {
                _context.Add(foodRecipe);
                await _context.SaveChangesAsync();

                var uploadsRootFolder = Path.Combine(_environment.WebRootPath, "recipephotos");
                if (!Directory.Exists(uploadsRootFolder))
                {
                    Directory.CreateDirectory(uploadsRootFolder);
                }
                string filename = foodRecipe.RecipeID + foodRecipe.Extension;
                var    filePath = Path.Combine(uploadsRootFolder, filename);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    await foodRecipe.File.FormFile.CopyToAsync(fileStream).ConfigureAwait(false);
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.FoodCategories, "CategoryID", "CategoryName", foodRecipe.CategoryID);
            return(View(foodRecipe));
        }
Beispiel #12
0
    public void MakeRecipe()
    {
        if (ingredients.Count == 0)
        {
            return;
        }

        FoodRecipe result = recipeDatabase.MakeRecipe(ingredients);

        if (result)
        {
            SoundManager.Instance.Play(1);

            foodEffect.ShowUI(result.sprite, result.Score);

            if (!fevertime)             // 피버타임이 아닐 때만 count
            {
                count++;
                FoodGameManager.Instance.Score += result.Score;
                FoodGameManager.Instance.AddSatisfy(result.Score);
            }
            else
            {
                FoodGameManager.Instance.Score += result.Score * 2;
                FoodGameManager.Instance.AddSatisfy(result.Score * 2);
            }
            switch (count)
            {
            case 1:
                comboImg.gameObject.SetActive(true);
                comboImg.sprite = combo1spr;
                StopCoroutine("HideCombo");
                StartCoroutine("HideCombo");
                break;

            case 2:
                comboImg.gameObject.SetActive(true);
                comboImg.sprite = combo2spr;
                StopCoroutine("HideCombo");
                StartCoroutine("HideCombo");
                break;

            case 3:
                onFeverStart();
                break;
            }
        }
        else
        {
            count = 0;                  // 콤보 연속 달성 실패 시 count 초기화

            scores.Clear();
            int sum = 0;
            foreach (var ing in ingredients)
            {
                sum += ing.score;
                scores.Add(ing.score);
            }
            FoodGameManager.Instance.Score += sum;
            FoodGameManager.Instance.AddSatisfy(sum);
        }

        ingredients.Clear();
        ingredientUI.ResetUI();
    }
Beispiel #13
0
        public IActionResult Get(string id)
        {
            FoodRecipe currentRecipe = accessor.Get <FoodRecipe>(id);

            return(Json(currentRecipe));
        }
Beispiel #14
0
    public static void BuildRecipeDatabase()
    {
        // CSV 데이터 파일 체크 및 파싱
        var dataDic = CSVParser.Read(rootDataPath + "/recipeDB");

        if (dataDic == null)
        {
            Debug.LogError("[Recp.DB Build] CSV parsing result is null");
            return;
        }

        // 데이터베이스 파일 생성 또는 초기화
        FoodRecipeDatabase db = Resources.Load <FoodRecipeDatabase>(rootDataPath + "/RecipeDatabase");

        if (db == null)
        {
            db = ScriptableObject.CreateInstance <FoodRecipeDatabase>();

            string databasePath = "Assets/Resources/" + rootDataPath + "/RecipeDatabase.asset";
            AssetDatabase.CreateAsset(db, databasePath);
            EditorUtility.SetDirty(db);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            Debug.Log("[Recp.DB Build] SO is created at " + databasePath);
        }
        else
        {
            db.Clear();
        }

        // 서브 데이터 디렉토리 체크
        string dataDirectoryPath = "Assets/Resources/" + rootDataPath + "/Recipes";

        if (!Directory.Exists(dataDirectoryPath))
        {
            Directory.CreateDirectory(dataDirectoryPath);
        }

        FoodIngredientDatabase ingredientDb = Resources.Load <FoodIngredientDatabase>(rootDataPath + "/IngredientDatabase");

        if (!ingredientDb)
        {
            Debug.LogError("[Recp.DB Build] Ingredient DB is null");
            return;
        }

        // 기존 파일 탐색
        FoodRecipe[] unconnectedData = Resources.LoadAll <FoodRecipe>(rootDataPath + "/Recipes");
        for (int i = 0; i < unconnectedData.Length; i++)
        {
            db.recipes.Add(unconnectedData[i]);
            db.recipes[i].SetData(dataDic[i], ingredientDb);
            EditorUtility.SetDirty(db.recipes[i]);
        }

        // 재사용할 데이터 파일 없으면 생성
        int charCount = dataDic.Count;

        for (int i = unconnectedData.Length; i < charCount; i++)
        {
            FoodRecipe newData = ScriptableObject.CreateInstance <FoodRecipe>();
            newData.SetData(dataDic[i], ingredientDb);

            string subDataPath = dataDirectoryPath + "/recp_" + i.ToString("0") + ".asset";
            AssetDatabase.CreateAsset(newData, subDataPath);
            EditorUtility.SetDirty(newData);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            db.recipes.Add(newData);
        }
        EditorUtility.SetDirty(db);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();

        Debug.Log("[Recp.DB Build] Success.");
    }