Beispiel #1
0
        public void AddCrush()
        {
            GameObject go   = content.AddChild(stepPrefab);
            RecipeStep step = go.GetComponent <RecipeStep>();

            step.icon.sprite = Resources.Load <Sprite>("Icons/crush");
            TooltipSpawner spawner = go.GetComponent <TooltipSpawner>();

            spawner.SetContent("Crush");
        }
Beispiel #2
0
        public void AddIngredient(Ingredient ingredient)
        {
            GameObject go = content.AddChild(stepPrefab);

            // Set icon
            if (!string.IsNullOrEmpty(ingredient.icon))
            {
                string resourcePath = Path.Combine("Icons", ingredient.icon);
                Sprite s            = Resources.Load <Sprite>(resourcePath);

                if (s != null)
                {
                    RecipeStep step = go.GetComponent <RecipeStep>();
                    step.icon.sprite = s;
                }
            }

            // Setup tooltip spawner
            TooltipSpawner spawner = go.GetComponent <TooltipSpawner>();

            spawner.SetContent(ingredient.name);
        }
Beispiel #3
0
        private void Start()
        {
            foreach (Ingredient i in Ingredients.instance.GetAllConfigs())
            {
                var iCopy = i;

                // Create button
                GameObject go     = contentScroller.AddChild(buttonPrefab);
                Button     button = go.GetComponent <Button>();
                button.onClick.AddListener(delegate() {
                    IngredientSelected(iCopy);
                });

                // Set icon
                if (!string.IsNullOrEmpty(i.icon))
                {
                    string resourcePath = Path.Combine("Icons", i.icon);
                    Sprite s            = Resources.Load <Sprite>(resourcePath);

                    if (s != null)
                    {
                        Image icon = go.GetComponentInChildren <Image>();
                        icon.sprite = s;
                    }
                }

                // Setup tooltip spawner
                string tooltipContent = iCopy.name + "\n";
                if (iCopy.order > -1)
                {
                    string order = "1st";
                    if (iCopy.order == 1)
                    {
                        order = "2nd";
                    }
                    if (iCopy.order == 2)
                    {
                        order = "3rd";
                    }
                    if (iCopy.order == 3)
                    {
                        order = "4th";
                    }
                    if (iCopy.order == 4)
                    {
                        order = "5th";
                    }
                    tooltipContent += string.Format("Must be added {0}\n", order);
                }
                if (iCopy.heat != 0)
                {
                    tooltipContent += string.Format("<color=yellow>Heating will {0} your score</color>\n", iCopy.heat == -1 ? "reduce" : "increase");
                }
                if (iCopy.stir != 0)
                {
                    tooltipContent += string.Format("<color=yellow>Stirring will {0} your score</color>\n", iCopy.stir == -1 ? "reduce" : "increase");
                }
                if (iCopy.crush != 0)
                {
                    tooltipContent += string.Format("<color=yellow>Crushing will {0} your score</color>\n", iCopy.crush == -1 ? "reduce" : "increase");
                }
                if (iCopy.neverMix != null)
                {
                    tooltipContent += "<color=red>Mixing with ";
                    tooltipContent += string.Join(", ", iCopy.neverMix.ToArray());
                    tooltipContent += " will kill your patient!</color>";
                }
                TooltipSpawner spawner = go.GetComponent <TooltipSpawner>();
                spawner.SetContent(tooltipContent);
            }
        }