예제 #1
0
    void addPotion(string s, string att)
    {
        for (int j = 0; j < playerInventory.Length; j++)
        {
            if (playerInventory[j].gameObject.transform.childCount == 0)
            {
                Transform panel = playerInventory[j].transform;

                GameObject      a    = Instantiate(defaultPotion);
                potionAttribute test = a.AddComponent <potionAttribute>();
                a.GetComponent <UnityEngine.UI.Image>().sprite = potions[s].img;
                a.name = potions[s].ingredientName;
                test.setAttribute(att);
                a.transform.SetParent(panel.transform, false);
                player.modalPopUp(potions[s].ingredientName, test.attribute, a.GetComponent <UnityEngine.UI.Image>().sprite);
                for (int h = 0; h < m_slots.Length; h++)
                {
                    if (m_slots[h] != null)
                    {
                        Destroy(m_slots[h]);
                    }
                }
                bool added = false;
                for (int k = 0; k < recipePages.transform.childCount; k++)
                {
                    if (recipePages.transform.GetChild(k).transform.FindChild("title").GetComponent <Text>().text != s)
                    {
                        added = false;
                    }
                    else
                    {
                        added = true;
                        k     = recipePages.transform.childCount - 1;
                    }
                }
                if (!added)
                {
                    addRecipePage(s);
                }

                bubbles.Play();
                break;
            }
        }
    }