Пример #1
0
        /// <summary>
        /// Draw stuff, handle mouse and keyboard events
        /// </summary>
        void OnGUI()
        {
            guiHotbar.UpdateDisplay(containerHotbar.ItemSlots, containerHotbar.FocusedSlotIndex);

            if (!active)
            {
                return;
            }

            guiPlayerInventory.UpdateDisplay(containerPlayerInventory.ItemSlots);

            if (guiOtherInventory != null)
            {
                guiOtherInventory.UpdateDisplay(containerOtherInventory.ItemSlots);
            }

            GuiSlotsBase   currentGui;
            ContainerSlots currentContainer;

            GetCurrent(out currentGui, out currentContainer);
            if (currentGui != null)
            {
                int slotIndex = currentGui.CursorOverSlot();
                if (slotIndex >= 0 && slotIndex < containerPlayerInventory.Capacity)
                {
                    GuiSlotsBase.DrawToolTip(currentContainer.GetItemStackAt(slotIndex));
                }
            }
            GuiSlotsBase.DrawItemStack(containerCursor.itemStack, Event.current.mousePosition.x, Event.current.mousePosition.y, itemSizeOnCursor * Screen.dpi);
        }
Пример #2
0
 /// <summary>
 /// Get the current container where player can interact with
 /// </summary>
 /// <param name="gui">output the gui</param>
 /// <param name="container">output the container</param>
 private void GetCurrent(out GuiSlotsBase gui, out ContainerSlots container)
 {
     gui = null; container = null;
     if (guiHotbar.CursorOverGui())
     {
         gui = guiHotbar; container = containerHotbar;
     }
     if (guiPlayerInventory.CursorOverGui())
     {
         gui = guiPlayerInventory; container = containerPlayerInventory;
     }
     if (guiOtherInventory != null && guiOtherInventory.CursorOverGui())
     {
         gui = guiOtherInventory; container = containerOtherInventory;
     }
 }