Exemplo n.º 1
0
    public void CreateMenuButton(Button button, Recipe recipe)
    {
        bool addRecipe = true;

        thisRecipe = recipe;
        newButton  = Instantiate(menuButton);
        newButton.transform.parent = content;
        content.sizeDelta          = new Vector2(content.rect.width, content.rect.height + 20);
        Debug.Log("Name of the recipe I have right now is (Create Menu Recipe) " + recipe.name);
        newButton.GetComponentInChildren <Text>().text = recipe.name;
        newButton.transform.localScale = new Vector3(1, 1, 1);
        RecipeCost recipeCost = newButton.gameObject.GetComponent <RecipeCost>();

        for (int i = 0; i < thisResturant.recipes.Count; i++)
        {
            if (thisResturant.recipes[i].recipe == recipe)
            {
                addRecipe = false;
                break;
            }
        }
        if (addRecipe)
        {
            thisResturant.AddRecipe(recipe);
        }
        Debug.Log("CreateMenuRecipes thisResturnat = " + thisResturant.GetInstanceID());
        thisResturant.recipeButtons.Add(newButton.gameObject);
        recipeCost.SetUp(thisRecipe, thisResturant);
    }
Exemplo n.º 2
0
    //Players menus are kept between players, they share one.
    //This only happens once
    public void OnClick()
    {
        bool addRecipe = true;

        for (int i = 0; i < thisRestaurant.recipes.Count; i++)
        {
            if (thisRestaurant.recipes[i].recipe == thisRecipe)
            {
                addRecipe = false;
            }
        }

        if (addRecipe)
        {
            thisRestaurant.recipes.Add(new RestaurantRecipe(thisRecipe));
        }

        savedRecipeScript = gameObject.GetComponentInParent <CreateSavedRecipeButtons>();
        Debug.Log("Name of the recipe I have right now is (Menu Add Button) " + thisRecipe.name);
        createMenuRecipeScript.FillBuildingRestaurant();                                        // Fills reference of Building Restruant
        if (addRecipe)
        {
            createMenuRecipeScript.CreateMenuButton(button, thisRecipe);                         // Creates the button and then adds it to the list of buttons and recipes
        }
        RecipeCost recipe = new RecipeCost();
    }
Exemplo n.º 3
0
        public void Should_Calulate_Cost_Of_Recipe()
        {
            var rc = new RecipeCost {
                Recipe = new Recipe {
                    Id = 1, RecipeName = "Oatmeal with Honey", Servings = 1
                }, RecipeComponents = recipeComponents
            };

            Assert.AreEqual(.68m, RecipeCostCalculator.CalculateTotalCost(rc));
        }
Exemplo n.º 4
0
    public void PopulateMenuButtons(RestaurantRecipe rr)
    {
        GameObject b = Instantiate(menuButton);

        b.transform.parent = content;
        content.sizeDelta  = new Vector2(content.rect.width, content.rect.height + 40);
        b.GetComponentInChildren <Text>().text = rr.recipe.name;
        b.transform.localScale = new Vector3(1, 1, 1);
        RecipeCost recipeCost = b.gameObject.GetComponent <RecipeCost>();

        recipeCost.SetUp(rr);
    }
Exemplo n.º 5
0
    //This is an attempt at repopulating the menu, not so successful
    //called for making the button only. Not adding a recipe to the restaurant
    public void CreateMenuButton(RestaurantRecipe rr)
    {
        GameObject b = Instantiate(menuButton);

        b.transform.parent = content;
        content.sizeDelta  = new Vector2(content.rect.width, content.rect.height + 40);
        Debug.Log("Name of the recipe I have right now is (Create Menu Recipe) " + rr.recipe.name);
        b.GetComponentInChildren <Text>().text = rr.recipe.name;
        b.transform.localScale = new Vector3(1, 1, 1);
        RecipeCost recipeCost = b.gameObject.GetComponent <RecipeCost>();

        thisResturant.recipeButtons.Add(b.gameObject);
        //recipeCost.SetUp(thisRecipe, thisResturant);
        recipeCost.SetUp(thisRecipe, thisResturant);
    }
    public void ResourceType()
    {
        for (int i = 0; i < SaveLoad.Instance.Recipe_Cost.Count; i++)
        {
            RecipeCost CraftingCost = SaveLoad.Instance.Recipe_Cost[i];

            if (Crafting.ResourceType == CraftingCost.ResourceType)
            {
                Crafting.InitialCost = CraftingCost.InitialCost;

                Crafting.Coefficient = CraftingCost.Coefficient;
                Crafting.InitialTime = CraftingCost.InitialTime;
            }
        }
    }
Exemplo n.º 7
0
        public static decimal CalculateTotalCost(RecipeCost recipeCost)
        {
            var costOfIngredients = CalculateCostOfIngredients(recipeCost.RecipeComponents);

            return(costOfIngredients * recipeCost.Recipe.Servings);
        }