Exemplo n.º 1
0
 void UpdateUI()
 {
     if (textObject != null)
     {
         textObject.text = _item.itemName + "\n x" + FlowerLibrary.GetPotionAmount(_item.itemName);
     }
 }
Exemplo n.º 2
0
 public void ActivatePotion()
 {
     if (FlowerLibrary.GetPotionAmount(_item.itemName) > 0)
     {
         if (_potionEffect.PotionEffectStart(FPSMovement.playerMovement))
         {
             EventManager.TriggerEvent(EventNameLibrary.DRINK_POTION, new EventParameter()
             {
                 boolParam     = false,
                 materialParam = _potionCameraEffect,
                 floatParam    = _potionDuration,
                 floatParam2   = _potionCameraEffectFadeTime
             });
             FlowerLibrary.IncrementPotion(_item.itemName, -1);
             UpdateUI();
         }
         else
         {
             Debug.Log("Potion already active");
         }
     }
     else
     {
         Debug.Log("Not enough of " + _item.itemName);
     }
 }
Exemplo n.º 3
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);
    }
Exemplo n.º 4
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");
        }
    }
Exemplo n.º 5
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);
                }
            }
        }
    }
Exemplo n.º 6
0
 public void Debug_AddAllIngredients()
 {
     for (int i = 0; i < _allIngredients.Count; i++)
     {
         FlowerLibrary.IncrementFlower(_allIngredients[i].GetFlowerName(), 50);
     }
     UpdateIngredients();
 }
Exemplo n.º 7
0
 public void Wipe()
 {
     Noise.Wipe();
     Player.Wipe();
     PrefabSpawnerSaveData.Wipe();
     MapGenerator.Wipe();
     FlowerLibrary.Wipe();
 }
Exemplo n.º 8
0
    public bool Interact(Transform interactor)
    {
        if (_enabled && (isUnderwater == false || !FPSMovement.IsSwimming()))
        {
            if (FlowerLibrary.GetFlowerDiscoverAmount(_flowerData.itemName) == 0)
            {
                BookManager.SetPickedFlower(_flowerData);
                if (onPickUpEvent != null)
                {
                    onPickUpEvent.Invoke(" " + _flowerData.itemName, _flowerData.itemIcon);
                }
            }
            //Pickup save system
            PickUp();
            //NotificationObject.name = _flowerData.itemName; // For notification system(not needed anymore, but leave it?)
            //NotificationObject.sprite = _flowerData.itemIcon; // For notification system(not needed anymore, but leave it?)

            Play_PickupSound(_flowerData.itemName);
            FlowerLibrary.IncrementFlower(_flowerData.itemName, _flowersReturned);
            if (_gameobjectOverload.Length == 0)
            {
                if (_pickupAlpha != null)
                {
                    GetComponent <MeshRenderer>().material.SetTexture("_Alpha", _pickupAlpha);
                    GetComponent <Collider>().enabled = false; //This may not work since there are multiple colliders
                }
                else
                {
                    Destroy(this.gameObject);
                }
            }
            else
            {
                foreach (GameObject gObject in _gameobjectOverload)
                {
                    if (_pickupAlpha != null)
                    {
                        gObject.GetComponent <MeshRenderer>().material.SetTexture("_Alpha", _pickupAlpha);
                    }
                    else
                    {
                        Destroy(gObject);
                    }
                }
                GetComponent <Collider>().enabled = false;//This may not work since there are multiple colliders
            }
            StartCoroutine(ShakeFlower(interactor, _pickupAnimationTime, _pickupAnimationForce));
            _pickupAction.Invoke();
            AlchemyOrganizer_2.DiscoverRecipes(_flowerData);
            if (_dissableTriggerafterPickup)
            {
                GetComponent <Collider>().enabled = false;
            }
            return(true); //Doesn't really have a purpose for this
        }
        return(false);
    }
Exemplo n.º 9
0
    public void AddPotion()
    {
        FlowerLibrary.IncrementPotion(_item.itemName, 1);
        Debug.Log("Adding one more " + _item.itemName + ", now there are " + FlowerLibrary.GetPotionAmount(_item.itemName));

        for (int i = 0; i < recipe.Count; i++)
        {
            FlowerLibrary.IncrementFlower(recipe[i].ingredient.itemName, -recipe[i].amount);
        }
        UpdateUI();
    }
Exemplo n.º 10
0
 void UpdatePotionAvailability(Recipe recipe)
 {
     if (FlowerLibrary.GetPotionAmount(recipe.potionData.itemName) > 0)
     {
         //recipe.potionButton.GetComponent<Image>().color = new Color(0.4f, 0.75f, 0.25f, 0.5f);
         recipe.potionButton.GetComponent <Button>().enabled = true;
     }
     else
     {
         //recipe.potionButton.GetComponent<Image>().color = new Color(0.35f, 0.35f, 0.35f, 0.5f);
         recipe.potionButton.GetComponent <Button>().enabled = false;
     }
 }
Exemplo n.º 11
0
 //Saves things that should be saved
 private void Save()
 {
     if (_save)
     {
         StartCoroutine(SaveIconAlpha());
         Noise.Save();
         PrefabSpawnerSaveData.Save();
         Player.Save();
         Menu.Save();
         MapGenerator.Save();
         FlowerLibrary.Save();
     }
 }
Exemplo n.º 12
0
    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); });
        }
    }
Exemplo n.º 13
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();
    }
Exemplo n.º 14
0
 public static void UpdateAfterLoad()
 {
     try
     {
         string[] allSavedFlowers = FlowerLibrary.GetAllFlowerNames();
         List <ItemDataContainer> allIngredients = alchemyOrganizer._allIngredients;
         for (int i = 0; i < allIngredients.Count; i++)
         {
             if (allSavedFlowers.Contains(allIngredients[i].itemName))
             {
                 DiscoverRecipes(allIngredients[i]);
             }
         }
     }
     catch (System.Exception e)
     {
         Debug.LogError(e);
     }
 }
Exemplo n.º 15
0
    //Load in stuff from memory, called on startup
    private void Load()
    {
        if (_load)
        {
            ValidateSave();
            Noise.Load();
            Player.Load();
            PrefabSpawnerSaveData.Load();
            MapGenerator.Load();
            Menu.Load();
            FlowerLibrary.Load();
            AlchemyOrganizer_2.UpdateAfterLoad();
        }

        //Used to make clear circle around player on spawn
        PrefabSpawnerSaveData.ClearStartArea(_meshSettings.NumVertsPerLine / 2, _clearAreaSize);

        Ready = true;
    }
Exemplo n.º 16
0
    public void Debug_AddAllIngredients()
    {
        //List<string> allFlowers = new List<string>();
        for (int i = 0; i < _recipieList.Count; i++)
        {
            UpdateRecipeToState(_recipieList[i], RecipeState.Available);
        }
        for (int i = 0; i < _allIngredients.Count; i++)
        {
            if (!_discoveredFlowers.Contains(_allIngredients[i]))
            {
                _discoveredFlowers.Add(_allIngredients[i]);
            }
            Debug.LogFormat("Adding flower {0}", _allIngredients[i]);
            FlowerLibrary.IncrementFlower(_allIngredients[i].itemName, 50);
        }

        //Debug.LogFormat("FLÖWERS: {0}", allFlowers.Count);

        //UpdateIngredients();
        UpdateUI();
    }
Exemplo n.º 17
0
    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); });
            }
        }
    }
Exemplo n.º 18
0
 new void OnEnable()
 {
     SetPageElementVisibility();
     _amountCounter.text = FlowerLibrary.GetFlowerAmount(_flowerName).ToString();
 }
Exemplo n.º 19
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);
    }
Exemplo n.º 20
0
 void Start()
 {
     imageObject.sprite = _item.itemIcon;
     textObject.text    = _item.itemName + "\n x" + FlowerLibrary.GetPotionAmount(_item.itemName);
 }
Exemplo n.º 21
0
 public void UpdateUI()
 {
     itemAmount      = FlowerLibrary.GetFlowerAmount(_item.itemName);
     textObject.text = _item.itemName + "\n x" + itemAmount;
 }