AddInventoryItem() public method

public AddInventoryItem ( Ingredient ingredient, int count ) : void
ingredient Ingredient
count int
return void
Ejemplo n.º 1
0
        public void OpenTransferModal()
        {
            Inventory     inventory     = UIManager.GetMenu <Inventory>();
            Container     container     = UIManager.GetMenu <Container>();
            TransferModal transferModal = UIManager.GetMenu <TransferModal>();
            int           amount        = 0;

            //TODO remove duplicated code!!
            if (toInventory)
            {
                //we need to add to the inventory
                amount = container.GetIngredientAmount(inventoryIngredient.ingredient);

                if (amount > 5)
                {
                    //open the modal, theres a bunch of things.
                    transferModal = UIManager.GetMenu <TransferModal>();
                    transferModal.Open(amount, inventoryIngredient, toInventory);

                    Close();
                }
                else
                {
                    //we just need to throw one over
                    Debug.Log("container -> inventory");
                    if (amount == 1)
                    {
                        Close();
                    }
                    inventory.AddInventoryItem(inventoryIngredient.ingredient, 1);
                    container.RemoveInventoryItem(inventoryIngredient.ingredient, 1);
                }
            }
            else
            {
                //we need to add to the container
                amount = inventory.GetIngredientAmount(inventoryIngredient.ingredient);

                if (amount > 5)
                {
                    //open the modal, theres a bunch of things.
                    transferModal = UIManager.GetMenu <TransferModal>();
                    transferModal.Open(amount, inventoryIngredient, toInventory);

                    Close();
                }
                else
                {
                    //we just need to throw one over
                    Debug.Log("inventory -> container");
                    if (amount == 1)
                    {
                        Close();
                    }
                    inventory.RemoveInventoryItem(inventoryIngredient.ingredient, 1);
                    container.AddInventoryItem(inventoryIngredient.ingredient, 1);
                }
            }
        }
Ejemplo n.º 2
0
        public void Transfer()
        {
            Inventory playerInventory = UIManager.GetMenu <Inventory>();
            Container container       = UIManager.GetMenu <Container>();

            if (toInventory)
            {
                playerInventory.AddInventoryItem(ingredient, Mathf.RoundToInt(slider.value));
                container.RemoveInventoryItem(ingredient, Mathf.RoundToInt(slider.value));
                Close();
            }
            else
            {
                playerInventory.RemoveInventoryItem(ingredient, Mathf.RoundToInt(slider.value));
                container.AddInventoryItem(ingredient, Mathf.RoundToInt(slider.value));
                Close();
            }
        }
Ejemplo n.º 3
0
        private void Initialize(bool b)
        {
            Inventory inventory = UIManager.GetMenu <Inventory>();

            if (UIManager.GetMenu <Inventory>().ContainerExchange)
            {
                if (b)
                {
                    Container container = UIManager.GetMenu <Container>();


                    //need to handle transfer
                    if (amount > 5)
                    {
                    }
                    else
                    {
                        //just throw one over
                        container.AddInventoryItem(SlotIngredient, 1);
                        inventory.RemoveInventoryItem(SlotIngredient, 1);
                    }
                }
            }
            else
            {
                //not exchanging!!
                if (slotIngredient as EquipableItem)
                {
                    if (GetComponent <DragHandler>().dragLength < 0.1f)
                    {
                        //they just clicked
                        Debug.Log("equipping");
                        EquipableItem ei = (EquipableItem)slotIngredient;
                        inventory.RemoveInventoryItem(slotIngredient, 1);

                        inventory.equipmentPanel.EquipItem(ei);

                        inventory.InitializeInventorySlots();

                        inventory.equipmentPanel.Initialize();
                    }
                    else
                    {
                        //they dragged and we need to handle this differently
                        Debug.Log("drag equipping");
                        EquipableItem ei = (EquipableItem)slotIngredient;
                        inventory.RemoveInventoryItem(slotIngredient, 1);

                        inventory.equipmentPanel.EquipItem(ei);

                        inventory.InitializeInventorySlots();

                        inventory.equipmentPanel.Initialize();
                    }
                }
                else
                {
                    //????
                }
            }

            CloseHoverTooltip();
        }