示例#1
0
 void InitializeItemsToCraft(string categoryName)
 {
     itemsInCategory = CraftingProperties.categoyItems[categoryName].Count;
     Debug.Log("Amount of items in caregory " + categoryName + ": " + itemsInCategory);
     for (int i = 0; i < ItemToCraftBoxes.Length; i++)
     {
         try
         {
             ItemToCraft iC = ItemToCraftBoxes[i].GetComponent <ItemToCraft>();
             if (CraftingProperties.categoyItems[categoryName].ElementAtOrDefault(i) != null)
             {
                 iC.ItemName = CraftingProperties.categoyItems[categoryName][i];
                 iC.GenerateImage();
                 //to be removed
                 if (i == 0)
                 {
                     CurrentItem = iC.ItemName;
                     CurrentCraftingItem currentCraftingItem = GameObject.Find("CurrentItemToCraft").GetComponent <CurrentCraftingItem>();
                     currentCraftingItem.UpdatePosition(0);
                     currentCraftingItem.UpdateItemTotalPosition(ItemToCraftBoxes.Length - 1);
                 }
             }
             else
             {
                 iC.ItemName = "";
                 iC.HideSprite();
             }
         }
         catch
         {
             Debug.Log(new System.Exception("No category available for this name"));
         }
     }
 }
示例#2
0
    public void ShiftItems(int offSet)
    {
        int    counter      = 0;
        string categoryName = CategorySelector.GetComponent <CurrentCategorySelector>().GetCurrentCategoryName();

        itemsInCategory = CraftingProperties.categoyItems[categoryName].Count;
        //Debug.Log("Amount of items in caregory " + categoryName + ": " + itemsInCategory);
        int startingPos = offSet - (ItemToCraftBoxes.Length - 1);

        // add a check to end of for loop if 4 is more then the count of item categories
        for (int i = startingPos; i < (startingPos + (ItemToCraftBoxes.Length)); i++)
        {
            try
            {
                ItemToCraft iC = ItemToCraftBoxes[counter].GetComponent <ItemToCraft>();
                if (CraftingProperties.categoyItems[categoryName].ElementAtOrDefault(i) != null)
                {
                    iC.ItemName = CraftingProperties.categoyItems[categoryName][i];
                    iC.GenerateImage();
                    //to be removed
                    if (i == 0)
                    {
                        CurrentItem = iC.ItemName;
                        CurrentCraftingItem currentCraftingItem = GameObject.Find("CurrentItemToCraft").GetComponent <CurrentCraftingItem>();
                        currentCraftingItem.UpdatePosition(0);
                        currentCraftingItem.UpdateItemTotalPosition(ItemToCraftBoxes.Length - 1);
                    }
                }
                else
                {
                    iC.HideSprite();
                }
                counter++;
            }
            catch
            {
                Debug.Log(new System.Exception("No category available for this name"));
            }
        }
    }