Exemplo n.º 1
0
    /**
     * Add a list of items to a group of chests
     */
    public void AddToChests(ChestSelectionMethod method, bool clearOnAdd, List <InventoryItem> items)
    {
        List <Chest> chests = GetChests(method);

        if (chests != null)
        {
            foreach (Chest chest in chests)
            {
                AddToChest(chest, clearOnAdd, items);
            }
        }
    }
Exemplo n.º 2
0
    /**
     * Add a list of items with the given item attributes to a group of chests
     */
    public void AddToChests(ChestSelectionMethod method, bool clearOnAdd, List <System.Type> itemAttributeTypes)
    {
        List <Chest> chests = GetChests(method);

        if (chests != null)
        {
            foreach (Chest chest in chests)
            {
                List <InventoryItem> items = itemAttributeTypes.Select(type => itemResource.GetRandomMatchingItem(type)).ToList();
                AddToChest(chest, clearOnAdd, items);
            }
        }
    }
Exemplo n.º 3
0
    /**
     * Get a list of all chests that will be selected given the selection mode
     */
    private List <Chest> GetChests(ChestSelectionMethod method)
    {
        List <Chest> chests = new List <Chest>();

        switch (method)
        {
        case ChestSelectionMethod.All:
            chests = FindObjectsOfType <Chest>().ToList();
            break;

        case ChestSelectionMethod.Selected:
        default:
            chests = Selection.gameObjects
                     .Where(gameObject => gameObject.GetComponent <Chest>() != null)
                     .Select(gameObject => gameObject.GetComponent <Chest>())
                     .ToList();
            break;
        }

        return(chests);
    }