Example #1
0
    private void EquipementNavigation()
    {
        if (Input.GetButtonDown("Inventory") || Input.GetKeyDown(KeyCode.Escape))
        {
            inventoryUI.Close();
            equipmentUI.Close();
            hudManager.statsDisplayer.OpenClose();
            hudManager.ActivateBackground(false);
            hudManager.graphicRaycaster.enabled = false;
            state = InputState.PlayerControl;
        }

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (inventoryUI.IsFocus())
            {
                if (inventoryUI.HasSelectedSlot())
                {
                    inventoryUI.SwapItems();
                }
                else
                {
                    if (equipmentUI.HasSelectedSlot())
                    {
                        inventoryUI.SelectSlot(false);
                        equipmentUI.UnequipItem();
                    }
                    else
                    {
                        inventoryUI.SelectSlot(true);
                    }
                }
            }
            else if (equipmentUI.IsFocus())
            {
                if (equipmentUI.HasSelectedSlot())
                {
                    equipmentUI.SwapItems();
                }
                else
                {
                    if (inventoryUI.HasSelectedSlot())
                    {
                        equipmentUI.TryEquipItem(inventoryUI.GetSelectedItem(), inventoryUI.GetSelectedItemIndex(), inventoryUI.GetSelectedSlotIndex());
                    }
                    else
                    {
                        equipmentUI.TryToSelectSlot();
                    }
                }
            }
            else
            {
                if (inventoryUI.HasSelectedSlot())
                {
                    inventory.DropItem(hudManager.inventoryUI.GetSelectedItemIndex());
                }
                else if (equipmentUI.HasSelectedSlot())
                {
                    equipmentUI.DisableSelection();
                }
            }
        }
        else if (Input.GetKeyDown(KeyCode.Mouse1))
        {
            if (inventoryUI.HasSelectedSlot())
            {
                inventoryUI.DisableSelection();
                hudManager.itemHandler.ResetIcon();
            }
            else if (equipmentUI.HasSelectedSlot())
            {
                equipmentUI.DisableSelection();
            }
        }
    }