示例#1
0
    // Use this for initialization
    void Start()
    {
        // Create a new list for the containers which enter our range
        m_containersInRange = new List <WORLD_Container>();


        // Get reference to the grid layout
        m_inventoryGridLayout = m_inventorySlotSubPanel.GetComponent <GridLayoutGroup>();
        m_containerGridLayout = m_containerSlotSubPanel.GetComponent <GridLayoutGroup>();

        // Set the cell sizes initially
        LIB_Inventory.AdjustGridCells(m_inventoryPanel, m_inventoryGridLayout, m_horSlotsToDisplay);
        LIB_Inventory.AdjustGridCells(m_containerPanel, m_containerGridLayout, m_horSlotsToDisplay);

        // Layout the slots to begin with, initiallizes and populates array also
        m_slotArrayInventory = LIB_Inventory.LayoutSlots(m_curBagSize, m_slotObject, m_inventorySlotSubPanel);

        if (m_slotArrayInventory.Length > 0)
        {
            LIB_Inventory.ForceGridLayoutGroupRebuild(m_inventorySlotSubPanel.GetComponent <RectTransform>());

            m_slotHighlighter.transform.position = m_slotArrayInventory[0].SLOTOBJ.transform.position;
            m_slotHighlighter.GetComponent <RectTransform>().sizeDelta = new Vector2(LIB_Inventory.CELL_DIMENSION * 1.1f, LIB_Inventory.CELL_DIMENSION * 1.1f);
        }
    }
示例#2
0
    // Open a container with the inventory (interface function)
    public void OpenContainer()
    {
        SetOnContainerMenu(false);

        WORLD_Container closestContainerInRange = SortContainers();

        if (closestContainerInRange != null)
        {
            // Layout the slots to begin with, initiallizes and populates array also
            m_slotArrayContainer = LIB_Inventory.LayoutSlots(closestContainerInRange.CONTAINER_SIZE, m_slotObject, m_containerSlotSubPanel);

            if (m_slotArrayContainer.Length > 0)
            {
                m_openContainer = closestContainerInRange;

                // Force the layout initially
                LIB_Inventory.ForceGridLayoutGroupRebuild(m_containerSlotSubPanel.GetComponent <RectTransform>());
            }

            ToggleInventory(1);
        }
        else
        {
            m_openContainer = null;
        }
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        // Do container distance and icon display cycling (every 0.1 seconds the list is checked)
        if (m_containersInRange.Count > 0)
        {
            if (m_closestContainterCheckCoroutine == null)
            {
                m_closestContainterCheckCoroutine = containerIconCheck();
                StartCoroutine(m_closestContainterCheckCoroutine);
            }
        }

        // Accomodate resolution change in inventory
        if (m_lastWidth != Screen.width)
        {
            // Set the cell sizes on rescale
            LIB_Inventory.AdjustGridCells(m_inventoryPanel, m_inventoryGridLayout, m_horSlotsToDisplay);
            LIB_Inventory.AdjustGridCells(m_containerPanel, m_containerGridLayout, m_horSlotsToDisplay);

            // Rebuild the inventory grid on adjust
            LIB_Inventory.ForceGridLayoutGroupRebuild(m_inventorySlotSubPanel.GetComponent <RectTransform>());

            // Adjust the highlighter slot position on resize
            m_slotHighlighter.transform.position = m_slotArrayInventory[0].SLOTOBJ.transform.position;
            m_slotHighlighter.GetComponent <RectTransform>().sizeDelta = new Vector2(LIB_Inventory.CELL_DIMENSION * 1.1f, LIB_Inventory.CELL_DIMENSION * 1.1f);
        }

        m_lastWidth = Screen.width;
    }
示例#4
0
    // Inventory state has "changed"
    void SetInventoryState(int palletteState)
    {
        // Toggle all inventory
        m_inventoryPanel.SetActive(m_inventoryOpen);
        m_inventoryBackground.SetActive(m_inventoryOpen);

        m_slotHighlighter.GetComponent <RectTransform>().sizeDelta = new Vector2(LIB_Inventory.CELL_DIMENSION * 1.1f, LIB_Inventory.CELL_DIMENSION * 1.1f);

        // Enable the slot highlighter
        m_slotHighlighter.SetActive(m_inventoryOpen);

        if (m_inventoryOpen)
        {
            // Pause Game
            Time.timeScale = 0;

            m_palletteState = palletteState;

            // Enable and disable all option windows accordingly
            switch (palletteState)
            {
            case 0:
                // Opened inventory in its default state (Left panel should display character info etc)
                m_equipmentPanel.SetActive(true);

                m_containerPanel.SetActive(false);

                m_invScrollTarget = Vector2.zero;
                m_slotHighlighter.transform.position = m_slotArrayInventory[0].SLOTOBJ.transform.position;

                break;

            case 1:
                // Opened inventory via a container (Left panel should display container contents panel)
                m_equipmentPanel.SetActive(false);

                m_containerPanel.SetActive(true);

                m_invScrollTarget = Vector2.zero;
                m_slotHighlighter.transform.position = m_slotArrayContainer[0].SLOTOBJ.transform.position;

                break;
            }
        }
        else
        {
            // Resume Game
            Time.timeScale = 1;

            m_invScrollTarget = Vector2.zero;

            LIB_Inventory.CleanContainer(m_containerSlotSubPanel);

            m_slotHighlighter.transform.position = m_slotArrayInventory[0].SLOTOBJ.transform.position;

            // Disable all option windows
            m_equipmentPanel.SetActive(false);
            m_containerPanel.SetActive(false);
        }

        // Update the game controller, static vars
        LIB_GameController.IS_INVENTORY_OPEN = m_inventoryOpen;
    }