Beispiel #1
0
    void Start()
    {
        this.AddResourcesToInventory
        (
            "Inventory/Resources/res_cloth",
            "Inventory/Resources/res_cloth",
            "Inventory/Resources/res_cotton",
            "Inventory/Resources/res_cotton",
            "Inventory/Resources/res_cotton"
        );

        // Crea el inventario con el número de casillas especificado
        for (int i = 1; i <= maxSlots; i++)
        {
            Instantiate(slotPrefab, slotsContainer.transform).name = "Slot " + i;
        }

        // Llena el inventario de objetos
        foreach (KeyValuePair <string, int> entry in inventory)
        {
            // Aquí se debe comprobar el número máximo de recursos agrupables.
            // Si por ejemplo hay 78 unidades de tela y se pueden agrupar máximo en grupos de 30,
            // se deberán agrupar en 3 casillas diferentes así: tela x30, tela x30 y tela x18
            Debug.Log(this.AddResource(entry.Key, entry.Value));
        }

        // Init existing items's internal state on scene start
        foreach (StackItem stackItem in AccessUtility.FindObjectsOfType <StackItem>())
        {
            stackItem.Init();
        }

        this.AddRecipe("Inventory/Recipes/rec_shirt");
    }
Beispiel #2
0
    private PriceGroup priceGroup;                                                                                      // Player's price group

    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        // Init existing items's internal state on scene start
        foreach (StackItem stackItem in AccessUtility.FindObjectsOfType <StackItem>())
        {
            stackItem.Init();
        }

        priceGroup = GetComponent <PriceGroup>();
        Debug.Assert(equipment && inventory && vendor && skills && inventoryStackGroup && equipmentStackGroup && vendorStackGroup && clickEquipInventory && priceGroup, "Wrong settings");
        priceGroup.ShowPrices(vendor.activeSelf);
    }