Esempio n. 1
0
    protected override bool OnInteractionBoxPressed(InteractionBox box, HandManager hand)
    {
        /* Get the item slot from the interaction box */
        UIItemSlot itemSlot = box.GetGameObject().GetComponent <UIItemSlot>();

        if (itemSlot == null)
        {
            return(false);
        }

        /* The store manager has to be setup */
        if (storeManager == null)
        {
            return(false);
        }

        /* See if either of our slot managers own this slot */
        bool catalogueOwnsSlot = barteringCatalogue.OwnsSlot(itemSlot);

        /* Get the item from the slot */
        SojournItem transfoerSojournItem = itemSlot.GetItem();

        if (transfoerSojournItem == null)
        {
            return(true);
        }
        Item transfer = transfoerSojournItem.GetItem();

        if (transfer == null)
        {
            return(true);
        }

        if (catalogueOwnsSlot)
        {
            CmdTransferFromStoreToInventory(storeManager.GetComponent <NetworkIdentity>().netId, transfer.item_name);
        }

        return(true);
    }
Esempio n. 2
0
    protected override bool OnItemDroppedOnInteractionBox(InteractionBox box, GameObject obj, HandManager hand)
    {
        /* See if this object is a sojourn item */
        SojournItem item = obj.GetComponent <SojournItem>();

        /* Is this an item? */
        if (item == null)
        {
            return(false);
        }

        /* Is this the relic or the journal? */
        bool relic   = obj.GetComponent <PlayerRelic>() != null;
        bool journal = obj.GetComponent <JournalManager>() != null;

        /* Are we dropping something into a slot? */
        PlayerToolbeltSlot slot = box.GetGameObject().GetComponent <PlayerToolbeltSlot>();

        if (slot == null)
        {
            /* This event isn't consumable by us */
            return(false);
        }

        /* Do we own this toolbelt slot? */
        if (!slot.GetSocketManager().hasAuthority)
        {
            /* We don't own this toolbelt slot */
            if (debug)
            {
                Debug.Log("PlayerToolbeltManager: We don't own this toolbelt slot!");
            }
            return(false);
        }

        /* Is this slot occupied? */
        if (slot.IsOccupied())
        {
            if (debug)
            {
                Debug.Log("PlayerToolbeltManager: Toolbelt slot is occupied.");
            }
            return(false);
        }

        if (debug)
        {
            Debug.Log("PlayerToolbeltManager Client: Player dropped something onto a slot!");
        }

        /* If this is the relic or the journal, return this to the slot where it's supposed to be */
        if (relic || journal)
        {
            /* Return this item to where it's supposed to go */
            if (!toolbelt.ReturnItem(item))
            {
                Debug.LogError("PlayerToolbeltManager: Failed to return item to it's correct slot.");
            }
        }

        /* Are we overlapping with a slot? */
        if (!slot.socketRestricted && !slot.IsOccupied())
        {
            if (debug)
            {
                Debug.Log("PlayerToolbeltManager Client: We're dropping something onto a slot!");
            }

            /* Attach this to something else */
            if (!item.ClientReattach(slot))
            {
                Debug.LogError("PlayerToolbeltManager Client: Failed to attach item to socket!");
                return(false);
            }

            /* Deliver the toolbet event */
            eventManager.OnToolbeltEvent(VRInteraction.InteractionEvent.OnItemPlacedInToolbelt, obj, slot, hand);

            /* This event was handled */
            return(true);
        }

        /* Is the player returning a restricted item? */
        if (slot.socketRestricted && slot.AcceptsAttachable(item))
        {
            /* Return the item to the toolbelt. */
            if (!slot.ReturnItem(item))
            {
                if (debug)
                {
                    Debug.Log("PlayerToolbeltManager Client: Failed to return restricted item!");
                }
                return(false);
            }

            if (debug)
            {
                Debug.Log("PlayerToolbeltManager Client: We returned a restricted item!");
            }

            /* Deliver the toolbet event */
            eventManager.OnToolbeltEvent(VRInteraction.InteractionEvent.OnItemPlacedInToolbelt, obj, slot, hand);

            /* The item was returned */
            return(true);
        }

        if (debug)
        {
            Debug.Log("PlayerToolbeltManager Client: We aren't overlapping with an open toolbelt slot.");
        }

        /* We couldn't consume this event */
        return(false);
    }