Ejemplo n.º 1
0
 public void updateInventoryMenu()
 {
     Debug.Log("Update inventory");
     if (itemDic != null)
     {
         foreach (KeyValuePair <ItemClass, int> entry in itemDic)
         {
             ItemSlot findInInventory = findItem(entry.Key);
             if (findInInventory != null)
             {
                 findInInventory.setNumber(entry.Value);
             }
             else
             {
                 ItemSlot empty = findEmptySlot();
                 if (empty == null)
                 {
                     Debug.Log("There are no empty slots");
                 }
                 empty.setNumber(entry.Value);
                 empty.item = entry.Key;
                 Sprite itemIcon = m_ItemIcon.getItemSpire(entry.Key.m_ItemName);
                 empty.setItemSprite(itemIcon);
             }
         }
     }
 }
Ejemplo n.º 2
0
    }    //end f'n ContainItem(ItemClass)

    /**A function to set the current hotkey's sprite to the corresponding to item [itemToSet], and to set the hotkey's text component to reflect the number of items in the player inventory*/
    public void setHotKeys(ItemClass itemToSet, int numberOfItems)
    {
        item = itemToSet;
        ItemIcon itemIcon = GetComponentInParent <ItemIcon> ();

        gameObject.GetComponent <Image> ().sprite = itemIcon.getItemSpire(itemToSet.m_ItemName);
        string new_text = "" + numberOfItems;

        gameObject.transform.parent.gameObject.GetComponentInChildren <Text> ().text = new_text;

//		Debug.Log(numberOfItems + " of " + itemToSet.m_ItemName.ToString() + " to set to hotkey, with sprite " + gameObject.GetComponent<Image> ().sprite.name);
    }