Exemple #1
0
 public void removeCurrentHoldItem()
 {
     if (myPlayer.currentHolded != null)
     {
         GameResources.PickedUpItemName itemName = myPlayer.currentHolded.getItemName();
         PopItem(myPlayer.currentHolded);
         myPlayer.DestroyHoldedItem();
         LetItemInHandByName(itemName);
     }
 }
Exemple #2
0
    public bool PopItem(PickedUpItems newItem)
    {
        GameResources.PickedUpItemName itemName = newItem.getItemName();
        int weight = 1;

        Debug.Log("POP " + itemName);

        int tmpCount;

        instanceList.Remove(newItem);

        if (backpack.TryGetValue(itemName, out tmpCount))
        {
            int index = itemToSlotIndex[itemName];

            if (tmpCount - 1 > 0)
            {
                backpack[itemName] = tmpCount - 1;

                slotList[index].updateItem(itemName, tmpCount - 1);
            }
            else
            {
                slotList[index].updateItem(GameResources.PickedUpItemName.DEFAULT, 0);

                backpack.Remove(itemName);
                slotIndexToItem.Remove(index);
                itemToSlotIndex.Remove(itemName);
                myPlayer = GameManagerForNetwork.Instance.LocalPlayer;
                if (myPlayer.currentHolded == newItem)
                {
                    myPlayer.DestroyHoldedItem();
                }
            }
        }
        else
        {
            return(false);
        }
        currentWeight -= weight;
        return(true);
    }