Esempio n. 1
0
    public void LoadIngredients(int index)
    {
        if (GameObject.FindGameObjectWithTag("Deleteable"))
        {
            foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Deleteable"))
            {
                GameObject.Destroy(obj);
            }
        }

        List <Ingredient> ingredients = _potionShop.GetRecipes()[index]._ingredients;

        _ingredientContent.GetComponent <RectTransform>().sizeDelta = new Vector2(260f, 140f * ingredients.Count);
        _selectedID = index;

        foreach (Ingredient ingredient in ingredients)
        {
            GameObject newIngredient = Instantiate(_ingredientButton) as GameObject;
            Item       newItem       = _databse.GetItemDataByID(ingredient._id);
            newIngredient.transform.SetParent(_ingredientContent);
            newIngredient.transform.localScale = Vector3.one;
            newIngredient.transform.GetChild(0).GetComponent <Image>().sprite = newItem.Icon;
            newIngredient.transform.GetChild(1).GetComponent <Text>().text    = _persistent.CheckItemQuantity(ingredient._id) + "\n___\n" + ingredient._quantity;
        }

        _cost.text     = "x " + _potionShop.GetRecipes()[index]._cost;
        _currency.text = "/ " + GameObject.FindGameObjectWithTag("Persistent").GetComponent <PersistentScript>()._magic;
    }
Esempio n. 2
0
    public void LoadInRecipeRequirements(int index)
    {
        if (GameObject.FindGameObjectWithTag("Deleteable"))
        {
            foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Deleteable"))
            {
                GameObject.Destroy(obj);
            }
        }
        List <Ingredient> ingredients = _recipeList[index]._ingredients;

        _combineList.GetComponent <RectTransform>().sizeDelta = new Vector2(280f, 200f * ingredients.Count);
        _selectedID = index;

        foreach (Ingredient ingredient in ingredients)
        {
            GameObject newIngredient = Instantiate(_ingredientPanel) as GameObject;
            Item       newItem       = _databse.GetItemDataByID(ingredient._id);
            newIngredient.transform.SetParent(_combineList);
            newIngredient.transform.localScale = Vector3.one;
            newIngredient.transform.GetChild(0).GetComponent <Text>().text    = newItem.Name;
            newIngredient.transform.GetChild(1).GetComponent <Image>().sprite = newItem.Icon;
            newIngredient.transform.GetChild(2).GetComponent <Text>().text    = _persistent.CheckItemQuantity(ingredient._id) + "\n___\n" + ingredient._quantity;
        }

        _currency.text = "x " + GameObject.FindGameObjectWithTag("Persistent").GetComponent <PersistentScript>()._heat;
    }