예제 #1
0
 public void AddItem(PocketItemType itemType, int amount)
 {
     for (int i = 0; i < maxInventorySize; i++)
     {
         AddItem(itemType);
     }
 }
예제 #2
0
    public pocketItemData FindItem(PocketItemType itemType)
    {
        for (int i = 0; i < Data.Count; ++i)
        {
            if (Data[i].Type == itemType)
            {
                return(Data[i]);
            }
        }

        return(null);
    }
    private void SetSlotImage(PocketItemType itemType, int index)
    {
        string slotName = getSlotName(index);

        pocketItemData itemData = Database.pItem.FindItem(itemType);

        GameObject tempSlotObject = getSlotObject(index);
        Image      image          = tempSlotObject.GetComponent <Image>();

        image.enabled  = true;
        tempSlotObject = itemData.TypePrefab;
        Sprite sprite = tempSlotObject.GetComponentInChildren <SpriteRenderer>().sprite;

        image.sprite = sprite;
    }
    void UpdateQuickInventoryView()
    {
        for (int i = 0; i < numberOfSlots; i++)
        {
            PocketItemType item = m_PocketModel.getInventoryItem(i);

            if (item != PocketItemType.Null)
            {
                SetSlotImage(item, i);
            }
            else
            {
                SetEmptySlotImage(i);
            }
        }
    }
예제 #5
0
    public void AddItem(PocketItemType itemType)
    {
        int emptyIndex = findFirstEmptyIndex();

        if (emptyIndex == -1)
        {
            return;
        }

        PocketItemArray[emptyIndex] = itemType;
        countNumberOfItems++;

        if (countNumberOfItems == 1)
        {
            changeSelectedSlotID(true);
        }
    }
예제 #6
0
    public void InventoryAction()
    {
        if (m_MovementModel.getIsCarrying() == true)
        {
            pocketItem = m_PickedUpObject.GetComponent <PocketBase>();

            if (pocketItem == null)
            {
                return;
            }

            if (m_PocketModel.GetNumberOfItems() == m_PocketModel.GetMaxSize())
            {
                Debug.Log("Full!");
                return;
            }

            m_PocketModel.AddItem(pocketItem.getType());
            Destroy(m_PickedUpObject.gameObject);
            SetUncarry();
        }
        else
        {
            PocketItemType item = m_PocketModel.GetSelectedItem();

            if (item == PocketItemType.Null)
            {
                return;
            }

            pocketItemData itemData   = Database.pItem.FindItem(item);
            GameObject     gameObject = itemData.TypePrefab;
            InstantiateInventoryItem(gameObject);

            m_PocketModel.RemoveSelectedItem();
        }
    }