Exemple #1
0
 void HandleItemDisappeared(PGISlotItem item, PGISlot dest)
 {
     if (dest == LinkedSlot)
     {
         CheckForDisconnect(item);
     }
 }
Exemple #2
0
 /// <summary>
 /// Used to trigger any 'CanUnequip' events in the item, slot, or inventory just before unequipping the item.
 /// If any attached handler wishes to invalidate this check they must
 /// set the <see cref="PGIModel.CanPerformAction"/> flag to <c>false</c>
 /// in the provided model parameter.
 /// <seealso cref="PGISlotItem.OnCanUnequip"/>
 /// <seealso cref="PGIModel.OnCanUnequipItem"/>
 /// <seealso cref="PGISlot.OnCanUnequipItem"/>
 /// </summary>
 /// <returns><c>true</c> if this instance can equip the specified storage destSlot; otherwise, <c>false</c>.</returns>
 /// <param name="storage">The <see cref="PGIModel"/> whose equipment slot this item is being removed from.</param>
 /// <param name="destSlot">The <see cref="PGISlot"/> that this item is being unequipped from.</param>
 public void TriggerCanUnequipEvents(PGIModel storage, PGISlot destSlot)
 {
     OnCanUnequip.Invoke(this, storage, destSlot);
     destSlot.OnCanUnequipItem.Invoke(this, storage, destSlot);
     if (storage != null)
     {
         storage.OnCanUnequipItem.Invoke(this, storage, destSlot);
     }
 }
Exemple #3
0
 void CanHandleMove(UnityAction onFailed, PGISlotItem item, PGISlot dest)
 {
     //don't allow linking through directly setting. Must have a source slot
     if (dest == null || dest.CorrespondingCell == null)
     {
         onFailed();
         return;
     }
 }
Exemple #4
0
 /// <summary>
 /// Handles the selection event from the StandardInputModule.
 /// This allows GamePads to highlight there current selection.
 /// This hihlighting is for the 'user cursor', not PGI's view
 /// hilighting that determines valid drop locations.
 /// </summary>
 /// <param name="eventData"></param>
 public override void OnSelect(BaseEventData eventData)
 {
     if (!Interactable)
     {
         return;
     }
     base.OnSelect(eventData);
     LastSlot = this;
     OnSelected.Invoke(eventData, this);
 }
Exemple #5
0
 public void CheckForDisconnect(PGISlotItem item)
 {
     if (LinkedSlot != null)
     {
         //reset if dest not us and item is no longer in our reference spot
         LinkedSlot.OnRemoveItem.RemoveListener(HandleItemDisappeared);
         LinkedSlot = null;
         OnUnlink.Invoke(item, this);
     }
 }
Exemple #6
0
 /// <summary>
 /// Used to trigger any OnStoreInInventoryFailed events for this item,
 /// and the associated inventory.
 /// <seealso cref="PGISlotItem.OnEquipFailed"/>
 /// <seealso cref="PGIModel.OnEquipItemFailed"/>
 /// <seealso cref="PGISlot.OnEquipItemFailed"/>
 /// </summary>
 /// <remarks>
 /// This method can potentially be called many times during drag 'n drop operations
 /// or when using the <see cref="PGIModel.Pickup"/> method.
 /// </remarks>
 /// <param name="storage">The <see cref="PGIModel"/> to which the equipment slot belongs.</param>
 /// <param name="destSlot">The <see cref="PGISot"/> that this item failed to equip to.</param>
 public void TriggerEquipFailedEvents(PGIModel storage, PGISlot destSlot)
 {
     OnEquipFailed.Invoke(this, storage, destSlot);
     if (destSlot != null)
     {
         destSlot.OnEquipItemFailed.Invoke(this, storage, destSlot);
     }
     if (storage != null)
     {
         storage.OnEquipItemFailed.Invoke(this, storage, destSlot);
     }
 }
Exemple #7
0
 /// <summary>
 /// Used to trigger any OnUnequip events for this item,
 /// the slot it is going in, and the associated inventory.
 /// <seealso cref="PGISlotItem.OnUnequip"/>
 /// <seealso cref="PGIModel.OnUnequipItem"/>
 /// <seealso cref="PGISlot.OnUnequipItem"/>
 /// </summary>
 /// <param name="storage">The <see cref="PGIModel"/> to which the equipment slot belongs.</param>
 /// <param name="destSlot">The <see cref="PGISot"/> that this item is being unequipped from.</param>
 public void TriggerUnequipEvents(PGIModel storage, PGISlot sourceSlot)
 {
     OnUnequip.Invoke(this, storage, sourceSlot);
     if (sourceSlot != null)
     {
         sourceSlot.OnUnequipItem.Invoke(this, storage, sourceSlot);
     }
     if (storage != null)
     {
         storage.OnUnequipItem.Invoke(this, storage, sourceSlot);
     }
 }
Exemple #8
0
        IEnumerator DelaySelect(PGISlot slot)
        {
            yield return(new WaitForEndOfFrame());

            if (slot.OverridingSlot != null)
            {
                slot.OverridingSlot.Select();
            }
            else
            {
                slot.Select();
            }
            yield break;
        }
Exemple #9
0
 /// <summary>
 /// Right-click event hook that rotates an item ina grid.
 /// </summary>
 /// <param name="eventData"></param>
 /// <param name="slot"></param>
 public void RotateItem(PointerEventData eventData, PGISlot slot)
 {
     if (eventData.button == PointerEventData.InputButton.Right)
     {
         if (slot != null && slot.Item != null)
         {
             if (slot.Item.RotatedDir == PGISlotItem.RotateDirection.None)
             {
                 slot.Item.Rotate(PGISlotItem.RotateDirection.CW);
             }
             else
             {
                 slot.Item.Rotate(PGISlotItem.RotateDirection.None);
             }
         }
     }//end  if
 }
Exemple #10
0
        /// <summary>
        /// Overrides the base implementation and feeds the item back to the source if any.
        /// This allows us to keep the item in both places at once.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="source"></param>
        void HandleMove(PGISlotItem item, PGISlot dest, PGISlot src)
        {
            if (dest == this)
            {
                var srcModel = src.CorrespondingCell;
                if (srcModel != null)
                {
                    //place the item back into the source it came from
                    PGIModel.RemoveItem(item, false);
                    PGIModel.StoreItem(item, srcModel, false);

                    //link ourself to the source
                    OriginalCell.Item = null;
                    LinkedSlot        = src;
                    src.OnRemoveItem.AddListener(HandleItemDisappeared);

                    OnLink.Invoke(item, this);
                }
            }
            else
            {
                CheckForDisconnect(item);
            }
        }