Esempio n. 1
0
 /// <summary>
 /// A handler that can be attached to a <see cref="PGIView.OnDragEndInvalid"/> event.
 /// </summary>
 /// <param name="data">The pointer event that was triggered.</param>
 /// <param name="item">The item being dropped.</param>
 /// <param name="returnSlot">The slot the item was returned to due to an invalid target.</param>
 /// <param name="dropTarget">The GameObject containing the UI element that was the drop target.</param>
 public void OnDrop(PointerEventData data, PGISlotItem item, PGISlot returnSlot, GameObject dropTarget)
 {
     if (DestInventory != null && item != null && dropTarget != null && dropTarget == this.gameObject)
     {
         if (DestInventory.CanStoreAnywhere(item, DestInventory.AutoEquip, DestInventory.AutoStack, null))
         {
             var oldModel = item.Model;
             if (oldModel.Drop(item))
             {
                 if (!DestInventory.Pickup(item))
                 {
                     oldModel.Pickup(item);
                 }
             }
         }
     }
     //TODO: we should trigger some kind of 'consume' or 'use' trigger here
 }
Esempio n. 2
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Ray        ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, 100))
         {
             if (hit.transform.gameObject == gameObject)
             {
                 if (DefaultInventory != null && Item != null)
                 {
                     DefaultInventory.Pickup(Item);
                 }
             }
         }
     }
     //PowerGridInventory.SaveLoad.Save("");
 }
Esempio n. 3
0
 /// <summary>
 /// This is the event that allows us to store the item
 /// in the inventory when we click on it in the game world.
 /// </summary>
 void OnMouseDown()
 {
     PickupToInventory.Pickup(Item);
 }