Esempio n. 1
0
    void GrantStartItemsAndUpdateUI()
    {
        if (_itemInstanceDatas == null)
        {
            _itemInstanceDatas = new Dictionary <int, InventoryInstanceData>();
        }

        InventoryInstanceData instanceData;
        ChapterUIManager      chapterUIManager = ChapterUIManager.instance;

        foreach (InventoryItemData itemData in _itemDatas)
        {
            if (_itemInstanceDatas.TryGetValue(itemData.itemId, out instanceData))
            {
                if (!_grantedStartItems && itemData.startCount > 0)
                {
                    instanceData.count += itemData.startCount;
                }
                chapterUIManager.UpdateInventoryItemCount(itemData, instanceData.count);
            }
            else
            {
                if (!_grantedStartItems && itemData.startCount > 0)
                {
                    instanceData = new InventoryInstanceData(itemData.itemId, itemData.startCount, 0);
                    _itemInstanceDatas.Add(itemData.itemId, instanceData);
                    chapterUIManager.UpdateInventoryItemCount(itemData, instanceData.count);
                }
            }
        }

        _grantedStartItems = true;
    }
Esempio n. 2
0
        public override void OnEnter()
        {
            ChapterUIManager chapterUIManager = ChapterUIManager.instance;

            if (chapterUIManager != null)
            {
                chapterUIManager.inventoryIconContainer.OpenZoom(itemId.Value);
            }
            else
            {
                Debug.LogError("No ChapterUIManager");
            }
            Finish();
        }
 void Awake()
 {
     s_instance = this;
     if (_tapBlocker != null)
     {
         _tapBlocker.SetActive(false);
     }
     if (Helper.IsRightUI())
     {
         _guiContainer = _rightUI;
     }
     else
     {
         _guiContainer = _bottomUI;
     }
 }
Esempio n. 4
0
    public void RemoveItem(int pId, int pCount = 1)
    {
        if (pCount < 1)
        {
            Debug.LogError("Can't remove less than 1 item");
            return;
        }

        InventoryItemData itemData = GetItemData(pId);

        if (itemData == null)
        {
            Debug.LogError("No data found for item id " + pId);
            return;
        }

        if (_itemInstanceDatas == null)
        {
            return;
        }
        else
        {
            InventoryInstanceData instanceData = null;
            if (_itemInstanceDatas.TryGetValue(pId, out instanceData))
            {
                ChapterUIManager chapterUIManager = ChapterUIManager.instance;
                instanceData.count -= pCount;
                chapterUIManager.UpdateInventoryItemCount(itemData, instanceData.count);

                if (instanceData.count <= 0)
                {
                    chapterUIManager.ClearSelectedItem();
                }


                //we dont delete the item if count is 0 because the presence of the item
                //indicates that the animation has already played
            }
        }
    }
Esempio n. 5
0
    public void AddItem(int pId, int pCount = 1)
    {
        if (pCount < 1)
        {
            Debug.LogError("Can't add less than 1 item");
            return;
        }

        InventoryItemData itemData = GetItemData(pId);

        if (itemData == null)
        {
            Debug.LogError("No data found for item id " + pId);
            return;
        }

        ChapterUIManager chapterUIManager = ChapterUIManager.instance;

        if (_itemInstanceDatas == null)
        {
            _itemInstanceDatas = new Dictionary <int, InventoryInstanceData> ();
            _itemInstanceDatas.Add(pId, new InventoryInstanceData(pId, pCount, 0));
            chapterUIManager.PlayAddInventoryItemAnimation(itemData, pCount);
        }
        else
        {
            InventoryInstanceData instanceData = null;
            if (_itemInstanceDatas.TryGetValue(pId, out instanceData))
            {
                instanceData.count += pCount;
                chapterUIManager.UpdateInventoryItemCount(itemData, instanceData.count, true);
            }
            else
            {
                _itemInstanceDatas.Add(pId, new InventoryInstanceData(pId, pCount, 0));
                chapterUIManager.PlayAddInventoryItemAnimation(itemData, pCount);
            }
        }
    }