コード例 #1
0
ファイル: Container.cs プロジェクト: drball/solburn
    /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

    public void TriggerContainer()
    {
        if (Panel.ActiveContainer == null)
        {
            //Activate the container UI:
            Panel.ActiveContainer = this;
            Panel.Panel.SetActive(true);
            Panel.HideToggleInfo();
            ShowInfo = false;

            if (ReArrangeItems == true)
            {
                ArrangeItems();
            }
            //Creaet slots and show items:
            Panel.ChangeSlots();
            Panel.RefreshItems();

            if (CustomEvents)
            {
                CustomEvents.OnPlayerOpenContainer();
            }
        }
        else if (Panel.ActiveContainer == this)
        {
            if (Panel.DraggingItem == true)
            {
                Slots[Panel.DragID].UI.gameObject.GetComponent <SlotUI>().DisableItemDrag();
            }

            SaveItems();

            //Desactivate the container UI:
            Panel.ActiveContainer = null;
            Panel.Panel.SetActive(false);
            ShowInfo = false;

            if (CustomEvents)
            {
                CustomEvents.OnPlayerCloseContainer();
            }
        }
    }
コード例 #2
0
    public void DragItem()      //Start dragging the item.
    {
        if (InventoryItem == true)
        {
            if (InvUI.Action == false && InvUI.InvManager.Slots[SlotID].IsTaken == true)
            {
                //Drag settings for this specific item:
                InvUI.DraggingItem = true;
                InvUI.InvManager.Slots[SlotID].Dragged = true;
                InvUI.DragSlot.SetActive(true);
                InvUI.DragSlot.GetComponent <Image>().sprite = InvUI.InvManager.Slots[SlotID].Item.GetComponent <Item>().Icon;

                InvUI.DragID = SlotID;

                //Desactivate item description on mouse hover.
                HoverScript.HoverActive = false;
                if (HoverScript.ItemInfo.gameObject.active == true)
                {
                    HoverScript.ItemInfo.gameObject.SetActive(false);
                }

                InvUI.RefreshItems();

                InvUI.Panel.transform.SetParent(InvUI.PanelDragPos.transform, true);
                InvUI.Panel.transform.SetParent(InvUI.UICanvas.transform, true);
            }
        }
        else if (ContainerItem == true && InvContainer.ActiveContainer != null && InvContainer.ActiveContainer.Slots[SlotID].IsTaken == true)
        {
            //Drag settings for this specific item:
            InvContainer.DraggingItem = true;
            InvContainer.ActiveContainer.Slots[SlotID].Dragged = true;

            InvContainer.DragSlot.SetActive(true);
            InvContainer.DragSlot.GetComponent <Image>().sprite = InvContainer.ActiveContainer.Slots[SlotID].Item.GetComponent <Item>().Icon;

            InvContainer.DragID = SlotID;

            //Desactivate item description on mouse hover.
            HoverScript.HoverActive = false;
            if (HoverScript.ItemInfo.gameObject.active == true)
            {
                HoverScript.ItemInfo.gameObject.SetActive(false);
            }

            InvContainer.RefreshItems();

            InvContainer.Panel.transform.SetParent(InvUI.PanelDragPos.transform, true);
            InvContainer.Panel.transform.SetParent(InvContainer.UICanvas.transform, true);
        }
        else if (EquipmentItem == true && EquipmentPanel.InvEquipment.EquipmentSlots[SlotID].IsTaken == true)
        {
            //Drag settings for this specific item:
            EquipmentPanel.DraggingItem = true;
            EquipmentPanel.InvEquipment.EquipmentSlots[SlotID].Dragged = true;

            EquipmentPanel.DragSlot.SetActive(true);
            EquipmentPanel.DragSlot.GetComponent <Image>().sprite = EquipmentPanel.InvEquipment.EquipmentSlots[SlotID].Item.GetComponent <Item>().Icon;

            EquipmentPanel.DragID     = SlotID;
            EquipmentPanel.DragTarget = -1;

            EquipmentPanel.InvEquipment.EquipmentSlots[SlotID].Icon.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);

            EquipmentPanel.Panel.transform.SetParent(InvUI.PanelDragPos.transform, true);
            EquipmentPanel.Panel.transform.SetParent(EquipmentPanel.UICanvas.transform, true);
        }
        else if (SkillBarItem == true && SkillBarPanel.InvSkillBar.SkillSlot[SlotID].IsTaken == true && SkillBarPanel.InvSkillBar.SkillSlot[SlotID].UseTimer == 0)
        {
            //Drag settings for this specific item:
            SkillBarPanel.DraggingItem = true;
            SkillBarPanel.InvSkillBar.SkillSlot[SlotID].Dragged = true;

            SkillBarPanel.DragSlot.SetActive(true);
            SkillBarPanel.DragSlot.GetComponent <Image>().sprite = SkillBarPanel.InvSkillBar.SkillSlot[SlotID].Item.GetComponent <Item>().Icon;

            SkillBarPanel.DragID     = SlotID;
            SkillBarPanel.DragTarget = -1;

            SkillBarPanel.InvSkillBar.SkillSlot[SlotID].Icon.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
            SkillBarPanel.InvSkillBar.SkillSlot[SlotID].Icon.transform.Find("Text").GetComponent <Text>().text = "";

            SkillBarPanel.Panel.transform.SetParent(InvUI.PanelDragPos.transform, true);
            SkillBarPanel.Panel.transform.SetParent(SkillBarPanel.UICanvas.transform, true);
        }
    }