Exemple #1
0
    void ClearRequest(Request r)
    {
        if (currentRequests.Contains(r))
        {
            int index = currentRequests.IndexOf(r);
            currentRequests.Remove(r);
            if (index == 0 && inst1 != null)
            {
                Destroy(inst1.gameObject);
                inst1 = null;
            }
            else if (index == 0 && inst2 != null)
            {
                Destroy(inst2.gameObject);
                inst2 = null;
            }

            else if (index == 1 && inst1 != null)
            {
                Destroy(inst1.gameObject);
                inst1 = null;
            }
            else
            {
                Destroy(inst2.gameObject);
                inst2 = null;
            }

            if (currentRequests.Count == 0 && onRegularTime)
            {
                newRequestAvailable = true;
            }
        }
    }
 public void ReorderCards()
 {
     for (int i = 0; i < GetRecipeCards().Length; i++)
     {
         RecipeCard    card      = GetRecipeCards()[i];
         RectTransform transform = card.GetComponent <RectTransform>();
         Vector2       position  = transform.anchoredPosition;
         position.x = paddingLeft;
         position.y = -paddingTop - (transform.sizeDelta.y * i + paddingTop * i);
         transform.anchoredPosition = position;
     }
 }
Exemple #3
0
        public IActionResult CreateRecipe(AddRecipeBindingModel recipeBindingModel, IFormFile fileUpload)
        {
            //Quick Validation for file uploads to avoid errors
            string image;

            //check if there is a new file to upload
            if (fileUpload != null)
            {
                //get new image
                image = GetFileBase64Async(fileUpload).Result;
            }
            else
            {
                //assign to placeholder's binary
                image = NoImagePlaceholder;
            }

            //Validation for empty input
            if (recipeBindingModel.Title != null || recipeBindingModel.Ingredients != null || recipeBindingModel.Method != null)
            {
                //create an entry in the recipes table
                var recipeToCreate = new Recipe
                {
                    Title       = recipeBindingModel.Title,
                    Image       = image,
                    Ingredients = recipeBindingModel.Ingredients,
                    Method      = recipeBindingModel.Method,
                    Servings    = recipeBindingModel.Servings,
                };
                repo.Recipes.Create(recipeToCreate);
                repo.Save();

                //create an entry in the recipe cards table
                var recipeCardToCreate = new RecipeCard
                {
                    Recipe = recipeToCreate,
                    Title  = recipeToCreate.Title,
                    Image  = image,
                };
                repo.RecipeCards.Create(recipeCardToCreate);
                repo.Save();
            }

            return(RedirectToAction("Index"));
        }
Exemple #4
0
    void AddRequestToList(Request r)
    {
        if (currentRequests.Count < REQUEST_MAX)
        {
            newRequestAvailable = false;
            currentRequests.Add(r);
            aud[1].Play();
            GameObject inst    = (Instantiate(recipeCardPrefab, MainCanvas.transform));
            RecipeCard current = inst.GetComponent <RecipeCard>();
            if (inst1 == null)
            {
                current.DrawRecipe(r.rec.name, r.rec.ingr);
                StartCoroutine(current.SlideIntoPosition(new Vector2(817, 271)));
                inst1 = current;
                if (onRegularTime)
                {
                    StartCoroutine(RequestTimer(r, 1));
                }
            }
            else if (inst2 == null)
            {
                current.DrawRecipe(r.rec.name, r.rec.ingr);
                StartCoroutine(current.SlideIntoPosition(new Vector2(527, 271)));
                inst2 = current;
                if (onRegularTime)
                {
                    StartCoroutine(RequestTimer(r, 2));
                }
            }

            if (onRegularTime)
            {
                if (currentRequests.Count == 2)
                {
                    newRequestAvailable = false;
                }
                else if (currentRequests.Count == 1)
                {
                    newRequestAvailable = false;
                    StartCoroutine(TimerBetweenRequests(timer(requestsDone) * r.timeLimit));
                }
            }
        }
    }
Exemple #5
0
 public void RemoveOrderCard(RecipeCard card)
 {
     orderUIList.Remove(card);
 }
 public void SetCard(RecipeCard card)
 {
     this.card = card;
 }