Beispiel #1
0
    public void RemoveItem(baseGroceryItemSO.GROCERY_ID itemID)
    {
        if (!m_DictionaryCart.ContainsKey(itemID))
        {
            return;
        }
        else
        {
            // If it returns true means it successfully reduced by 1
            if (m_DictionaryCart[itemID].DecreaseItemCountButtonPressed())
            {
                NumOfItems--;

                RecalculatePrice();
            }
            // If it didnt that means theres no more items and it should be deleted
            // hopefully
            else
            {
                // Destroy Object
                GroceryItemObject itemToRemove = m_DictionaryCart[itemID];
                itemToRemove.transform.parent = null;
                Destroy(itemToRemove.gameObject);
                m_DictionaryCart.Remove(itemID);
                // Scroll Height Recalculate
                RecalculateScrollHeight();
                // Price Recalculate
                RecalculatePrice();

                NumOfItems--;
            }
        }
    }
Beispiel #2
0
    public void AddItem(baseGroceryItemSO.GROCERY_ID itemID)
    {
        if (m_DictionaryCart.ContainsKey(itemID))
        {
            m_DictionaryCart[itemID].IncreaseItemCountButtonPressed();
            // Price Recalculate

            NumOfItems++;

            RecalculatePrice();
            return;
        }
        // New Entry
        GroceryItemObject newItem = Instantiate(m_GroceryItemPrefab);

        newItem.AssignSO(GroceryItemDatabase.Instance.GetGroceryItem(itemID));
        m_DictionaryCart.Add(itemID, newItem);
        // Parent new Entry under for Vertical Layout
        newItem.transform.parent = m_CartDisplayItemParent.transform;
        // Scroll Height Recalculate
        RecalculateScrollHeight();
        // Price Recalculate
        RecalculatePrice();

        NumOfItems++;
    }