Ejemplo n.º 1
0
    /*
     *  void ActivatePotion(PotionType type, float duration, int )
     *  {
     *          Debug.Log("Activating Potion");
     *          _modifiers.PotionEffectStart(FPSMovement.playerMovement);
     *          //StartCoroutine(ActivatePotion(_potionDuration));
     *  }*/
    /*IEnumerator ActivatePotion(float t)
     *  {
     *          _modifiers.SpeedPot(FPSMovement.playerMovement);
     *          Debug.Log("Speed Potion Applied");
     *          yield return new WaitForSeconds(t);
     *          _modifiers.SpeedPotionEnd(FPSMovement.playerMovement);
     *          Debug.Log("Speed Potion Removed");
     *  }*/
    void AddIngredient(ItemLoader ingredient)
    {
        if (FlowerLibrary.GetFlowerAmount(ingredient.GetFlowerName()) > 0)
        {
            Debug.Log("Name of ingredient object: " + ingredient.gameObject.name + "\n Current number of ingredients: " + _currentIngredients.Count);
            if (_currentIngredients.Count < 3)
            {
                int key = FindNextEmptyKey();
                _currentIngredients.Add(key, ingredient);

                GameObject imageGO   = ingredient.GetComponentInChildren <Image>().gameObject;
                GameObject slotImage = Instantiate(imageGO, _slots[key].transform);

                IsRecipe(GetIngredientNames());

                Debug.Log("Ingredient index: " + key);

                /*Image ingredientImage = ingredient.GetComponentInChildren<Image>();
                 *              Image empty = _slotImages.Find(x => x == _emptySlot);
                 *              //Debug.Log("SlotImage: " + empty.gameObject);
                 *
                 *              empty.gameObject.GetComponent<Image>().sprite = ingredientImage.sprite;
                 *              empty.gameObject.GetComponent<Image>().col	or = ingredientImage.color;*/
            }
            else
            {
                Debug.Log("Slots are full");
            }
        }
        else
        {
            Debug.Log("Not enough ingredients");
        }
    }
Ejemplo n.º 2
0
    /*void RecipeStateChange(RecipeState newState, Recipe recipe)
     *  {
     *          if (newState == RecipeState.Unavailable)
     *          {
     *                  if (recipe.state != RecipeState.Unknown)
     *                  {
     *                          Debug.LogError("Attempted to change Recipe to state Unavailable when not unknown");
     *                  }
     *                  else
     *                  {
     *                          recipe.state = RecipeState.Unavailable;
     *                          recipe.button.SetActive(true);
     *                          recipe.button.GetComponent<Button>().enabled = false;
     *                  }
     *          }
     *          if (newState == RecipeState.Available)
     *          {
     *                  if (recipe.state == RecipeState.Unknown)
     *                  {
     *                          recipe.state = RecipeState.Available;
     *                          recipe.button.SetActive(true);
     *                  }
     *                  else if (recipe.state == RecipeState.Unavailable)
     *                  {
     *                          recipe.state = RecipeState.Available;
     *                          recipe.button.GetComponent<Button>().enabled = true;
     *                  }
     *                  else
     *                  {
     *                          Debug.LogError("Attempted to change Recipe to Available when already available");
     *                  }
     *          }
     *  }
     */
    /*
     *  void ActivatePotion(PotionType type, float duration, int )
     *  {
     *          Debug.Log("Activating Potion");
     *          _modifiers.PotionEffectStart(FPSMovement.playerMovement);
     *          //StartCoroutine(ActivatePotion(_potionDuration));
     *  }*/
    /*IEnumerator ActivatePotion(float t)
     *  {
     *          _modifiers.SpeedPot(FPSMovement.playerMovement);
     *          Debug.Log("Speed Potion Applied");
     *          yield return new WaitForSeconds(t);
     *          _modifiers.SpeedPotionEnd(FPSMovement.playerMovement);
     *          Debug.Log("Speed Potion Removed");
     *  }*/

    // void CreateAllRecipes()
    // {
    //     //string debug = "Creating all recipes, possible recipes are: ";
    //     //Debug.Log("Number of recipes: " + _availablePotions.Count);
    //     for (int i = 0; i < _availablePotions.Count; i++)
    //     {
    //         //Debug.Log("LOOP");
    //         List<ItemDataContainer> recipe = _availablePotions[i].GetRecipe();
    //         _recipieList.Add(recipe);
    //         /*debug += "\n \t ";
    //for (int j = 0; j < recipe.Count; j++)
    //{
    //	debug += recipe[j] + ", ";
    //}*/
    //     }
    //     //Debug.Log(debug);
    // }

    //void UpdateIngredients()
    //{
    //    foreach (ItemLoader ingredient in _allIngredients)
    //    {
    //        ingredient.UpdateUI();
    //    }
    //}
    bool CraftPotion(Recipe potionRecipe)
    {
        //Debug.Log("Test Crafting");
        for (int i = 0; i < potionRecipe.ingredientsData.Length; i++)
        {
            ItemDataContainer comparableItem;
            if (potionRecipe.ingredientsData[i].amount <= FlowerLibrary.GetFlowerAmount(potionRecipe.ingredientsData[i].ingredient.itemName))
            {
            }
            else if (FindSameSymbol(potionRecipe.ingredientsData[i].ingredient, potionRecipe.ingredientsData[i].amount, out comparableItem))
            {
                potionRecipe.ingredientsData[i].ingredient = comparableItem;
                potionRecipe.ingredientImages[i].sprite    = comparableItem.itemIcon;
            }
            else
            {
                Debug.LogFormat("Not enough of ingredient {0}", potionRecipe.ingredientsData[i].ingredient.itemName);
                return(false);
            }
        }

        potionRecipe.potionScript.AddPotion(potionRecipe.ingredientsData);

        UpdatePotionAvailability(potionRecipe);
        UpdateUI();
        return(true);
    }
Ejemplo n.º 3
0
    void UpdateUI()
    {
        //List<Transform> recipeHolders = new List<Transform>();

        //recipeHolders.AddRange(_pages[0].transform.GetComponentsInChildren<Transform>().Where(x => x.parent == _pages[0].transform));
        //recipeHolders.AddRange(_pages[1].transform.GetComponentsInChildren<Transform>().Where(x => x.parent == _pages[0].transform));


        for (int i = 0; i < _recipieList.Count; i++)
        {
            _recipieList[i].potionAmount.text = FlowerLibrary.GetPotionAmount(_recipieList[i].potionData.itemName).ToString();

            //Debug.LogFormat("Sanity Check RecipeList: {0}", _recipieList[i].ingredientAmount);
            for (int ii = 0; ii < _recipieList[i].ingredientAmount.Length; ii++)
            {
                try
                {
                    _recipieList[i].ingredientAmount[ii].text = string.Format("{0}/{1}",
                                                                              FlowerLibrary.GetFlowerAmount(_recipieList[i].ingredientsData[ii].ingredient.itemName), _recipieList[i].ingredientsData[ii].amount);
                }
                catch (System.NullReferenceException e)
                {
                    Debug.LogErrorFormat("Encountered NullReference in the AlchemyOrganizerV2 during UpdateUI. This was encountered on the {0}th recipe at the {1}th ingredient", i, ii);
                }
            }
        }
    }
Ejemplo n.º 4
0
    public void CraftPotion()
    {
        bool hasIngredients = true;

        foreach (ItemLoader ingredient in _currentIngredients.Values)
        {
            if (1 > FlowerLibrary.GetFlowerAmount(ingredient.GetItemData().itemName))
            {
                hasIngredients = false;
            }
        }

        if (_result != null && hasIngredients)
        {
            _result.AddPotion();
        }
        //ClearAllIngredients();
        UpdateIngredients();
    }
Ejemplo n.º 5
0
 new void OnEnable()
 {
     SetPageElementVisibility();
     _amountCounter.text = FlowerLibrary.GetFlowerAmount(_flowerName).ToString();
 }
Ejemplo n.º 6
0
 public void UpdateUI()
 {
     itemAmount      = FlowerLibrary.GetFlowerAmount(_item.itemName);
     textObject.text = _item.itemName + "\n x" + itemAmount;
 }
Ejemplo n.º 7
0
    bool FindSameSymbol(ItemDataContainer data, int amount, out ItemDataContainer hasSame)
    {
        Debug.Log("Test");
        for (int i = 0; i < _allIngredients.Count; i++)
        {
            if (data.symbol == null || _allIngredients[i] == null)
            {
                Debug.Log("Null Fail");
                hasSame = null;
            }
            else if (object.ReferenceEquals(_allIngredients[i].symbol, data.symbol) && FlowerLibrary.GetFlowerAmount(_allIngredients[i].itemName) >= amount)
            {
                Debug.Log("Not Null Fail");
                hasSame = _allIngredients[i];
                return(true);
            }
        }

        Debug.Log("test");
        hasSame = null;
        return(false);
    }