Пример #1
0
    /// <summary> This is clientside </summary>
    public void StoreItem(GameObject Performer, EquipSlot equipSlot, GameObject item)
    {
        InventorySlot storageInvSlot = storageObj.NextSpareSlot();

        if (storageInvSlot != null && item != gameObject)
        {
            var playerInvSlot = InventoryManager.GetSlotFromOriginatorHand(Performer, equipSlot);
            StoreItemMessage.Send(gameObject, Performer, playerInvSlot.equipSlot, true);
            SoundManager.PlayAtPosition("Rustle0" + Random.Range(1, 6).ToString(), PlayerManager.LocalPlayer.transform.position);
            ObjectBehaviour itemObj = item.GetComponent <ObjectBehaviour>();
            itemObj.parentContainer = objectBehaviour;
        }
    }
Пример #2
0
    public static StoreItemMessage Send(GameObject storage, GameObject player, EquipSlot playerEquipSlot, bool storeItem, EquipSlot storeEquipSlot = 0)
    {
        StoreItemMessage msg = new StoreItemMessage
        {
            PlayerEquipSlot = playerEquipSlot,
            StoreEquipSlot  = storeEquipSlot,
            player          = player.GetComponent <NetworkIdentity>().netId,
            Storage         = storage.GetComponent <NetworkIdentity>().netId,
            StoreItem       = storeItem,
        };

        msg.Send();
        return(msg);
    }
Пример #3
0
 //Means OnDrop while drag and dropping an Item. OnDrop is the UISlot that the mouse pointer is over when the user drops the item
 public void OnDrop(PointerEventData data)
 {
     if (UIManager.DragAndDrop.ItemSlotCache != null && UIManager.DragAndDrop.ItemCache != null)
     {
         if (itemSlot.inventorySlot.IsUISlot)
         {
             if (itemSlot.Item == null)
             {
                 if (itemSlot.CheckItemFit(UIManager.DragAndDrop.ItemCache))
                 {
                     if (PlayerManager.LocalPlayerScript != null)
                     {
                         if (!PlayerManager.LocalPlayerScript.playerMove.allowInput ||
                             PlayerManager.LocalPlayerScript.IsGhost)
                         {
                             return;
                         }
                     }
                     if (UIManager.DragAndDrop.ItemSlotCache.inventorySlot.IsUISlot)
                     {
                         PlayerManager.LocalPlayerScript.playerNetworkActions.CmdUpdateSlot(itemSlot.equipSlot, UIManager.DragAndDrop.ItemSlotCache.equipSlot);
                     }
                     else
                     {
                         var storage = UIManager.DragAndDrop.ItemSlotCache.inventorySlot;
                         StoreItemMessage.Send(storage.Owner, PlayerManager.LocalPlayerScript.gameObject, itemSlot.equipSlot, false, storage.equipSlot);
                     }
                 }
             }
             else
             {
                 var storage = itemSlot.Item.GetComponent <InteractableStorage>();
                 if (storage)
                 {
                     storage.StoreItem(PlayerManager.LocalPlayerScript.gameObject, UIManager.DragAndDrop.ItemSlotCache.equipSlot, UIManager.DragAndDrop.ItemCache);
                 }
             }
         }
         else
         {
             var storage = itemSlot.inventorySlot.Owner.GetComponent <InteractableStorage>();
             storage.StoreItem(PlayerManager.LocalPlayerScript.gameObject, UIManager.DragAndDrop.ItemSlotCache.equipSlot, UIManager.DragAndDrop.ItemCache);
         }
     }
 }
Пример #4
0
    /// <summary>
    /// Swap the item in the current slot to itemSlot
    /// </summary>
    public bool SwapItem(UI_ItemSlot itemSlot)
    {
        if (isValidPlayer())
        {
            if (CurrentSlot != itemSlot)
            {
                var pna = PlayerManager.LocalPlayerScript.playerNetworkActions;

                if (CurrentSlot.Item == null)
                {
                    if (itemSlot.Item != null)
                    {
                        if (itemSlot.inventorySlot.IsUISlot)
                        {
                            pna.CmdUpdateSlot(CurrentSlot.equipSlot, itemSlot.equipSlot);
                        }
                        else
                        {
                            StoreItemMessage.Send(itemSlot.inventorySlot.Owner, PlayerManager.LocalPlayerScript.gameObject, CurrentSlot.equipSlot, false, itemSlot.equipSlot);
                        }
                        return(true);
                    }
                }
                else
                {
                    if (itemSlot.Item == null)
                    {
                        if (itemSlot.inventorySlot.IsUISlot)
                        {
                            pna.CmdUpdateSlot(itemSlot.equipSlot, CurrentSlot.equipSlot);
                        }
                        else
                        {
                            StoreItemMessage.Send(itemSlot.inventorySlot.Owner, PlayerManager.LocalPlayerScript.gameObject, CurrentSlot.equipSlot, true);
                        }
                        return(true);
                    }
                }
            }
        }
        return(false);
    }