Ejemplo n.º 1
0
    public void swapWith(MenuSlot releaseTo)
    {
        MenuSlotItem meTemp           = this.getItem();
        MenuSlotItem youTemp          = releaseTo.getItem();
        bool         changedInventory = false;

        //If the two items can't be combined
        if (!combineSuccess(releaseTo))
        {
            //Maybe add/remove the items to the home inventories
            //tip to future William: only use one | so the evaluation doesn't short curcuit
            changedInventory = changedInventory | maybeAddToInventory(releaseTo);
            changedInventory = changedInventory | maybeRemoveFromInventory(releaseTo);
            changedInventory = changedInventory | releaseTo.maybeAddToInventory(this);
            changedInventory = changedInventory | releaseTo.maybeRemoveFromInventory(this);

            //Swap them
            this.setItem(youTemp);
            releaseTo.setItem(meTemp);
        }

        if (changedInventory && releaseTo.type != SlotType.DisplaySlot)
        {
            HomeBaseUIController hbuic = GetComponentInParent <HomeBaseUIController>();
            hbuic.updateInventoryItemCount();
        }
    }