コード例 #1
0
    /// <summary>
    /// General function to try to equip the item in the active hand
    /// </summary>
    public void Equip()
    {
        // Is the player allowed to interact? (not a ghost)
        if (!isValidPlayer())
        {
            return;
        }

        // Is there an item to equip?
        if (!CurrentSlot.IsFull)
        {
            return;
        }

        //This checks which UI slot the item can be equiped to and swaps it there
        UI_ItemSlot itemSlot = InventorySlotCache.GetSlotByItemType(CurrentSlot.Item);

        if (itemSlot != null)
        {
            // If we couldn't equip item into pocket, let's try the other pocket!
            if (!SwapItem(itemSlot) && itemSlot.eventName == "storage02")
            {
                SwapItem(InventorySlotCache.GetSlotByEvent("storage01"));
            }
        }
        else
        {
            Logger.LogError("No slot type was found for this object for auto equip", Category.UI);
        }
    }
コード例 #2
0
    public static void ClientClearInvSlot(PlayerNetworkActions pna, EquipSlot equipSlot)
    {
        var inventorySlot = pna.Inventory[equipSlot];

        inventorySlot.Item = null;
        var UIitemSlot = InventorySlotCache.GetSlotByEvent(inventorySlot.equipSlot);

        UIitemSlot.Clear();
    }
コード例 #3
0
    public static void ClientEquipInInvSlot(PlayerNetworkActions pna, GameObject item, EquipSlot equipSlot)
    {
        var inventorySlot = pna.Inventory[equipSlot];

        inventorySlot.Item = item;
        var UIitemSlot = InventorySlotCache.GetSlotByEvent(inventorySlot.equipSlot);

        UIitemSlot.SetItem(item);
    }
コード例 #4
0
    /// <summary>
    /// General function to try to equip the item in the active hand
    /// </summary>
    public void Equip()
    {
        // Is the player allowed to interact? (not a ghost)
        if (!isValidPlayer())
        {
            return;
        }

        // Is there an item to equip?
        if (CurrentSlot.Item == null)
        {
            Logger.Log("!CurrentSlot.IsFull");
            return;
        }

        //This checks which UI slot the item can be equiped to and swaps it there
        UI_ItemSlot itemSlot = InventorySlotCache.GetSlotByItemType(CurrentSlot.Item);

        if (itemSlot != null)
        {
            //Try to equip the item into the appropriate slot
            if (!SwapItem(itemSlot))
            {
                //If we couldn't equip the item into it's primary slot, try the pockets!
                if (!SwapItem(InventorySlotCache.GetSlotByEvent(EquipSlot.storage01)))
                {
                    //We couldn't equip the item in pocket 1. Try pocket2!
                    //This swap fails if both pockets are full, do nothing if fail
                    SwapItem(InventorySlotCache.GetSlotByEvent(EquipSlot.storage02));
                }
            }
        }

        else
        {
            Logger.LogError("No slot type was found for this object for auto equip", Category.UI);
        }
    }