예제 #1
0
    //Returns a list of items for a specific bodypart
    public List <Item_SO> GetItemsFromBodypart(Character.Bodypart bodypart)
    {
        List <Item_SO> result = new List <Item_SO>();

        switch (bodypart)
        {
        case Character.Bodypart.Head:
            result = _headCategory._itemList;
            break;

        case Character.Bodypart.Chest:
            result = _chestCategory._itemList;
            break;

        case Character.Bodypart.Legs:
            result = _legsCategory._itemList;
            break;

        default:
            Debug.Log("Unknown bodypart");
            break;
        }

        return(result);
    }
예제 #2
0
    //Clean then populate the item grid for the specified bodypart
    //IMPROVEMENT NOTE: Repopulate the grid if it current bodypart != from requested one
    public void UpdateOnBodypart(Character.Bodypart bodypart)
    {
        UpdateItemCategory(bodypart);
        _itemGrid.GetComponent <ItemGrid>().PopulateGrid(bodypart);

        _activeItem = ItemsManager.instance.GetItemsFromBodypart(bodypart)[0];
        DisplayItem(_activeItem);
    }
예제 #3
0
    //Clear the item grid from its item slots and create add new ones, fed from the itemCategory list matching the requested bodypart
    public void PopulateGrid(Character.Bodypart bodypart)
    {
        foreach (Transform child in transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        List <Item_SO> itemList = ItemsManager.instance.GetItemsFromBodypart(bodypart);

        foreach (Item_SO item in itemList)
        {
            GameObject newItemSlot = Instantiate(_itemSlot, transform);
            newItemSlot.GetComponent <ItemSlot>()._item = item;

            if (item._icon)     //if the item (data) contains an icon, use it as icon in the item slot, else use the item illustration
            {
                newItemSlot.GetComponent <ItemSlot>()._icon.sprite = item._icon;
            }
            else
            {
                newItemSlot.GetComponent <ItemSlot>()._icon.sprite = item._illustration;
            }
        }
    }
예제 #4
0
 //Display the bodypart name in the "Item category" part of the UI
 public void UpdateItemCategory(Character.Bodypart bodypart)
 {
     _itemCategoryName.GetComponent <Text>().text = bodypart.ToString().ToUpper();
 }