示例#1
0
        public override void _Ready()
        {
            this.SetMouseFilter(Control.MouseFilterEnum.Ignore);
            var bag = new InventoryBag();


            bag.AnchorLeft = 0f;
            bag.AnchorTop  = 0;

            bag.MarginLeft  = 60;
            bag.MarginRight = -60;
            bag.MarginTop   = 100;
            this.GetNode("Panel").AddChild(bag);
        }
示例#2
0
 public void setPickedUpItem(InventoryItem item = null, InventoryBag bag = null, bool ignoreJustPickedUpItem = false)
 {
     if (pickedUpItem != null)
     {
         /**
          * if we already had an item picked up but we are either
          * dropping it, or switching it to another item, then
          * notify the item that this is happening
          */
         pickedUpItem.getInventoryNode().onDrop();
         var parent = pickedUpItem.getInventoryNode().GetParentOrNull <Node>();
         if (parent != null)
         {
             parent.RemoveChild(pickedUpItem.getInventoryNode());
         }
         if (bag != null)
         {
             bag.AddChild(pickedUpItem.getInventoryNode());
         }
         if (this.mouseDragNode != null)
         {
             this.RemoveChild(mouseDragNode);
         }
     }
     if (item != null)
     {
         /**
          * notify the item that it was picked up
          */
         item.getInventoryNode().onPickup(bag);
         var parent = item.getInventoryNode().GetParentOrNull <Node>();
         if (parent != null)
         {
             parent.RemoveChild(item.getInventoryNode());
         }
         this.mouseDragNode = (Control)(item.getInventoryNode().getMouseDragNode().Duplicate());
         this.mouseDragNode.SetMouseFilter(Control.MouseFilterEnum.Ignore);
         this.mouseDragNode.SetGlobalPosition(this.GetViewport().GetMousePosition() - (item.getInventoryNode().GetCustomMinimumSize() / 2));
         this.AddChild(this.mouseDragNode);
     }
     pickedUpItem = item;
     if (pickedUpItem != null && !ignoreJustPickedUpItem)
     {
         justPickedUpItem = true;
     }
 }
示例#3
0
 public void onDrop(InventoryBag bag = null)
 {
     this.Modulate = new Color(1, 1, 1, 1);
     this.shouldHaveHoverBorder = true;
     this.Update();
 }
示例#4
0
 public void onPickup(InventoryBag bag = null)
 {
     this.Modulate = new Color(1, 1, 1, 0.5f);
     this.shouldHaveHoverBorder = false;
     this.Update();
 }