示例#1
0
    protected override void OnGUI()
    {
        //reset colours
        for (uint i = 0; i < (uint)EPlayerHand.MAX; i++)
        {
            m_loadout_handFrames[i].color = Color.white;
        }
        for (int i = 0; i < (int)EAugmentSlot.MAX; ++i)
        {
            m_augmentSlots_Frame[i].color = Color.white;
        }

        foreach (GameObject go in m_inventoryitemElements)
        {
            UI_DragableItem dragableItem = go.GetComponentInChildren <UI_DragableItem>();
            HandleItemDragging(dragableItem);
        }
    }
示例#2
0
    private void HandleItemDragging(UI_DragableItem dragableItem)
    {
        if (dragableItem)
        {
            if (dragableItem.IsDragging())
            {
                //Move the element!
                Rect canvasSize = UI_CanvasManager.GetCanvas().pixelRect;
                dragableItem.GetParentTransform().SetParent(UI_CanvasManager.GetCanvas().transform);
                dragableItem.GetParentTransform().localPosition = UI_CanvasManager.ConvertScreenPositionToCanvasLocalPosition(UI_CanvasManager.GetMousePositionFromScreenCentre());

                if (dragableItem.GetParentItem().GetItemType() == EItemType.WEAPON)
                {
                    //Hovering over HAND SLOTS
                    for (uint i = 0; i < (uint)EPlayerHand.MAX; i++)
                    {
                        //if your hovering over a UI hand
                        if (UI_CanvasManager.IsPointInsideRect(m_loadout_hands[i].rectTransform, dragableItem.GetParentTransform().localPosition))
                        {
                            m_loadout_handFrames[i].color = Color.green;
                        }
                    }
                }
                else
                {
                    for (uint i = 0; i < (uint)EPlayerHand.MAX; i++)
                    {
                        m_loadout_handFrames[i].color = Color.red;
                    }
                }

                if (dragableItem.GetParentItem().GetItemType() == EItemType.AUGMENT)
                {
                    Augment aug = dragableItem.GetParentItem() as Augment;

                    //Hovering over AUGMENTS
                    for (int i = 0; i < (int)EAugmentSlot.MAX; ++i)
                    {
                        EAugmentSlot augSlot = (EAugmentSlot)i;

                        if (UI_CanvasManager.IsPointInsideRect(m_augmentSlots[i].rectTransform, dragableItem.GetParentTransform().localPosition))
                        {
                            if (m_player.m_playerAugmentHandler.CanAttachAugmentToSlot(augSlot, aug))
                            {
                                m_augmentSlots_Frame[i].color = Color.green;
                            }
                            else
                            {
                                m_augmentSlots_Frame[i].color = Color.red;
                            }
                        }
                    }
                }
                else
                {
                    //display bad colours for aug slots
                    for (int i = 0; i < (int)EAugmentSlot.MAX; ++i)
                    {
                        m_augmentSlots_Frame[i].color = Color.red;
                    }
                }
            }
        }
    }