示例#1
0
    public void Show()
    {
        CharacterController2D.DisableMovement();
        interactionController.DisableInteracting();

        gameObject.SetActive(true);
        inventoryPanel.Show(InventoryState.MIXING);
        EventSystem.current.SetSelectedGameObject(slot0.gameObject);
    }
示例#2
0
    public void DisableInputs()
    {
        inventoryManager.HideMixingMenu();
        inventoryManager.HideInventory();

        CharacterController2D.DisableMovement();
        InventoryManager.DisableInventory();
        interactionController.DisableInteracting();
#if UNITY_ANDROID
        inventoryButton.SetActive(false);
#endif
    }
示例#3
0
    public void Show(InventoryState state)
    {
        this.state = state;

        foreach (Transform children in contentPanel.transform)
        {
            Destroy(children.gameObject);
        }

        CharacterController2D.DisableMovement();
        interactionController.DisableInteracting();

        firstButton = null;
        List <string> items = Inventory.GetItems();

        items.Sort();

        List <Button> buttonList = new List <Button>();

        for (int i = 0; i < items.Count; i++)
        {
            string id   = items[i];
            Item   item = interactionsDataBase.GetItem(id);

            InventoryItem inventoryItem = Instantiate(inventoryItemPrefab);

#if UNITY_ANDROID
            inventoryItem.GetComponent <Image>().raycastTarget = true;
#endif

            inventoryItem.item        = item;
            inventoryItem.icon.sprite = item.GetSprite();

            inventoryItem.inventoryPanel = this;
            inventoryItem.index          = i;

            inventoryItem.gameObject.name = "slot_" + id;
            Button btInventoryItem = inventoryItem.GetComponent <Button>();

#if !UNITY_ANDROID
            Navigation navigation = btInventoryItem.navigation;
            navigation.mode = Navigation.Mode.Explicit;
#endif

            btInventoryItem.onClick.AddListener(
                delegate
            {
                OnItemSelected(inventoryItem.item);
            });

            inventoryItem.transform.SetParent(contentPanel.transform, false);

            buttonList.Add(btInventoryItem);
        }

#if !UNITY_ANDROID
        for (int i = 0; i < buttonList.Count; i++)
        {
            Button bt = buttonList[i];

            Navigation navigation = bt.navigation;

            navigation.mode = Navigation.Mode.Explicit;
            if (i == 0)
            {
                navigation.selectOnLeft = buttonList[buttonList.Count - 1];
                if (buttonList.Count == 1)
                {
                    navigation.selectOnRight = buttonList[0];
                }
                else
                {
                    navigation.selectOnRight = buttonList[i + 1];
                }
            }
            else if (i == buttonList.Count - 1)
            {
                navigation.selectOnLeft  = buttonList[i - 1];
                navigation.selectOnRight = buttonList[0];
            }
            else
            {
                navigation.selectOnLeft  = buttonList[i - 1];
                navigation.selectOnRight = buttonList[i + 1];
            }

            bt.navigation = navigation;
        }
#endif

        gameObject.SetActive(true);

        if (buttonList.Count > 0)
        {
            firstButton = buttonList[0];
        }

        if (state == InventoryState.LOOKING)
        {
            recipeBook.Show();
            clock.Show();
        }
        else
        {
            recipeBook.Hide();
        }
    }