Ejemplo n.º 1
0
        /// <summary>
        ///     Stacks the attached item onto the other item and returns true if it was stacked.
        /// </summary>
        /// <param name="other">The item that will act as the stack.</param>
        /// <returns>True if attached item was stacked onto other item, otherwise false.</returns>
        public bool AvoidSwap(ISwappable other)
        {
            // if the other swappable is an item
            if (other.GetType() == typeof(Item))
            {
                // cast the swappable to an item
                Item otherItem = (Item)other;

                // if the item types are the same we can potentially stack them
                if (otherItem.itemType == itemType)
                {
                    int remainder = stackItems(this, otherItem);
                    if (remainder == 0)
                    {
                        UnityEngine.Object.Destroy(Icon.gameObject);
                        return(true);
                    }
                    else
                    {
                        SubtractFromAmt(int.MaxValue);
                        AddToAmt(remainder);
                        return(true);
                    }
                }
                return(false);
            }
            Debug.Log("Avoid");
            return(true);
        }
Ejemplo n.º 2
0
        private void OpenSellPanel()
        {
            // get the swappable attached to the mouse
            ISwappable swappable = swapManager.GetAttachedSwappable();

            // if there is a swappable and its an item
            if (swappable != null && swappable.GetType() == typeof(Item))
            {
                // open the sell panel with that item.
                Item item = (Item)swappable;
                Shop.OpenSellPanel(item);

                // return the attached item back to its slot
                swapManager.StopSwap();
            }
        }