void UpdateUI()
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            PotionLoader potion     = _allPotions[i];
            string       potionName = potion.GetPotionItemData().itemName;

            Transform child = transform.GetChild(i);
            child.GetComponentInChildren <Text>().text = potionName + "\n x" + FlowerLibrary.GetPotionAmount(potionName);

            //go.GetComponent<Button>().onClick.AddListener( delegate { ActivateSelectedRegion(MENU_ACTIVATE_BUTTON); });
        }
    }
Exemple #2
0
    /*List<string> GetItemNames()
     *  {
     *          List<string> itemNames = new List<string>();
     *          for (int i = 0; i < _allIngredients.Count; i++)
     *          {
     *                  itemNames.Add(_allIngredients[i].GetFlowerName());
     *          }
     *          return itemNames;
     *  }*/

    bool IsRecipe(List <ItemDataContainer> recipe)
    {
        if (_recipieList.Count < 1)
        {
            CreateAllRecipes();
        }

        bool isRecipe = false;
        int  index    = -1;

        for (int i = 0; i < _recipieList.Count; i++)
        {
            if (CompareRecipes(recipe, _recipieList[i]))
            {
                isRecipe = true;
                index    = i;
                break;
            }
        }

        if (isRecipe)
        {
            //Debug.Log("Recipe available");
            if (_potionSlot.transform.childCount > 0)
            {
                Destroy(_potionSlot.transform.GetChild(0).gameObject);
            }

            //int index = _recipieList.IndexOf(recipe);
            //Debug.Log("Index of recipe is: " + index);
            //PotionLoader potion = _availablePotions[index];
            _result = _availablePotions[index];
            GameObject imageGO = _result.gameObject.GetComponentInChildren <Image>().gameObject;

            RectTransform image = Instantiate(imageGO, _potionSlot.transform).GetComponent <RectTransform>();
            image.localPosition = Vector3.zero;
        }
        else
        {
            _result = null;
            if (_potionSlot.transform.childCount > 0)
            {
                Destroy(_potionSlot.transform.GetChild(0).gameObject);
            }
        }

        return(isRecipe);
    }
    void SetUpRegions()
    {
        regionPositions = new Vector3[8];
        for (int i = 0; i < regionPositions.Length; i++)
        {
            float sinValue = Mathf.Sin((6.28f / 8) * i);
            float cosValue = Mathf.Cos((6.28f / 8) * i);

            regionPositions[i] = new Vector3(sinValue, cosValue, 0);
        }

        if (8 < _allPotions.Count)
        {
            Debug.LogError("Either all potions don't have regions or all regions don't have a potion in PotionWheelManager");
        }
        else
        {
            for (int i = 0; i < _allPotions.Count; i++)
            {
                PotionLoader potion     = _allPotions[i];
                string       potionName = potion.GetPotionItemData().itemName;
                //int ind = i;

                GameObject go = Instantiate(_wheelRegion, transform);
                go.transform.position = transform.position + regionPositions[i] * regionDistanceFromCenter * Camera.main.pixelHeight / 2;
                Debug.Log("Potion wheel region distance: " + regionDistanceFromCenter * Camera.main.pixelHeight);
                //GameObject image = Instantiate(_wheelRegion, go.transform);

                go.GetComponentInChildren <Text>().text = potionName + "\n x" + FlowerLibrary.GetPotionAmount(potionName);
                Image imageSprite = go.transform.GetChild(0).GetComponent <Image>();
                imageSprite.sprite = potion.GetPotionItemData().itemIcon;

                go.name = i.ToString() + "Potion ";
                //go.GetComponent<Button>().onClick.AddListener( delegate { ActivateSelectedRegion(MENU_ACTIVATE_BUTTON); });
            }
        }
    }