Пример #1
0
        public virtual void OnDragMove(BaseEventData eventData)
        {
            PointerEventData pointerData = ((PointerEventData)eventData);

            if (pointerData == null)
            {
                return;
            }

            if (DATABASE_INVENTORY != null &&
                DATABASE_INVENTORY.inventorySettings.onDragGrabItem && this.item.sprite != null)
            {
                InventoryUIManager.OnDragItem(this.item.sprite, true);
            }

            if (pointerData.pointerCurrentRaycast.gameObject == null)
            {
                return;
            }
            GameObject target      = pointerData.pointerCurrentRaycast.gameObject;
            ItemUI     otherItemUI = target.GetComponent <ItemUI>();

            if (otherItemUI != null)
            {
                Button otherButton = pointerData.pointerCurrentRaycast.gameObject.GetComponentInChildren <Button>();
                if (otherButton != null)
                {
                    this.HighlightButton(this.button, true);
                    this.HighlightButton(otherButton, true);
                }

                eventData.Use();
            }
        }
        public static void CloseInventory()
        {
            if (!IsInventoryOpen())
            {
                return;
            }

            InventoryUIManager.RequireInstance();
            InventoryUIManager.Instance.Close();
        }
        public override bool Check(GameObject target)
        {
            switch (this.inventory)
            {
            case State.IsOpen:
                return(InventoryUIManager.IsInventoryOpen());

            case State.IsClosed:
                return(!InventoryUIManager.IsInventoryOpen());
            }

            return(false);
        }
        // INITIALIZERS: --------------------------------------------------------------------------

        private void Awake()
        {
            InventoryUIManager.Instance = this;
            if (transform.childCount >= 1)
            {
                this.inventoryRoot     = transform.GetChild(0).gameObject;
                this.inventoryAnimator = this.inventoryRoot.GetComponent <Animator>();
            }

            if (this.floatingItem != null)
            {
                this.floatingItemRT = this.floatingItem.GetComponent <RectTransform>();
            }
            InventoryUIManager.OnDragItem(null, false);
        }
Пример #5
0
        // EXECUTABLE: -------------------------------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            switch (this.menuType)
            {
            case MENU_TYPE.Inventory:
                if (this.actionType == ACTION_TYPE.Open)
                {
                    InventoryUIManager.OpenInventory();
                }
                if (this.actionType == ACTION_TYPE.Close)
                {
                    InventoryUIManager.CloseInventory();
                }
                break;
            }

            return(true);
        }
Пример #6
0
        public virtual void OnDragBegin(BaseEventData eventData)
        {
            if (DATABASE_INVENTORY != null && DATABASE_INVENTORY.inventorySettings.cursorDrag != null)
            {
                Cursor.SetCursor(
                    DATABASE_INVENTORY.inventorySettings.cursorDrag,
                    DATABASE_INVENTORY.inventorySettings.cursorDragHotspot,
                    CursorMode.Auto
                    );
            }

            if (DATABASE_INVENTORY != null &&
                DATABASE_INVENTORY.inventorySettings.onDragGrabItem && this.item.sprite != null)
            {
                InventoryUIManager.OnDragItem(this.item.sprite, true);
            }

            eventData.Use();
        }
Пример #7
0
        // INITIALIZERS: --------------------------------------------------------------------------

        private void Awake()
        {
            InventoryUIManager.Instance = this;
            this.currentItems           = new Dictionary <int, InventoryUIItem>();

            if (this.itemsContaineScrollRect == null)
            {
                this.itemsContaineScrollRect.GetComponentInChildren <ScrollRect>();
            }

            if (transform.childCount >= 1)
            {
                this.inventoryRoot     = transform.GetChild(0).gameObject;
                this.inventoryAnimator = this.inventoryRoot.GetComponent <Animator>();
            }

            if (this.floatingItem != null)
            {
                this.floatingItemRT = this.floatingItem.GetComponent <RectTransform>();
            }
            InventoryUIManager.OnDragItem(null, false);
        }
        // STATIC METHODS: ------------------------------------------------------------------------

        public static void OpenInventory()
        {
            InventoryUIManager.RequireInstance();
            InventoryUIManager.Instance.Open();
        }
Пример #9
0
        public virtual void OnDragEnd(BaseEventData eventData)
        {
            if (DATABASE_INVENTORY != null && DATABASE_INVENTORY.inventorySettings.cursorDrag != null)
            {
                Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
            }

            InventoryUIManager.OnDragItem(null, false);
            PointerEventData pointerData = ((PointerEventData)eventData);

            if (pointerData == null)
            {
                return;
            }
            if (pointerData.pointerCurrentRaycast.gameObject == null)
            {
                return;
            }

            GameObject      target            = pointerData.pointerCurrentRaycast.gameObject;
            IgniterDropItem targetDrop        = target.GetComponent <IgniterDropItem>();
            EquipSlotUI     targetEquipSlotUI = target.GetComponent <EquipSlotUI>();
            ItemUI          targetItemUI      = target.GetComponent <ItemUI>();

            if (targetDrop != null)
            {
                targetDrop.OnDrop(this.item);
                eventData.Use();
            }
            else if (targetEquipSlotUI != null)
            {
                targetEquipSlotUI.OnDrop(this.item);
                eventData.Use();
            }
            else if (targetItemUI == null)
            {
                bool mouseOverUI = EventSystemManager.Instance.IsPointerOverUI();
                if (!mouseOverUI && DATABASE_INVENTORY.inventorySettings.canDropItems && this.item.prefab != null)
                {
                    Vector3 position  = pointerData.pointerCurrentRaycast.worldPosition + (Vector3.up * 0.1f);
                    Vector3 direction = position - HookPlayer.Instance.transform.position;

                    if (direction.magnitude > DATABASE_INVENTORY.inventorySettings.dropItemMaxDistance)
                    {
                        position = (
                            HookPlayer.Instance.transform.position +
                            direction.normalized * DATABASE_INVENTORY.inventorySettings.dropItemMaxDistance
                            );
                    }

                    Instantiate(this.item.prefab, position, Quaternion.identity);
                    InventoryManager.Instance.SubstractItemFromInventory(this.item.uuid, 1);
                }

                eventData.Use();
            }
            else if (this.item.uuid != targetItemUI.item.uuid)
            {
                Button otherButton = pointerData.pointerCurrentRaycast.gameObject.GetComponentInChildren <Button>();
                if (otherButton != null)
                {
                    this.HighlightButton(this.button, false);
                    this.HighlightButton(otherButton, false);
                }

                InventoryManager.Instance.UseRecipe(this.item.uuid, targetItemUI.item.uuid);
                eventData.Use();
            }
        }
Пример #10
0
 public static void CloseInventory()
 {
     InventoryUIManager.RequireInstance();
     InventoryUIManager.Instance.Close();
 }