Exemple #1
0
    public void SetSelectedItem(CatalogItem item)
    {
        selectedItem = item;

        CurrentItemName.text = selectedItem.DisplayName;
        CurrentItemDesc.text = selectedItem.Description;
        ItemCount.text       = string.Format("{0}/{1}", selectedIndex + 1, pfItems.Count);
        // refresh the UI

        currentIconId = PF_GameData.GetIconByItemById(item.ItemId);
        var icon = GameController.Instance.iconManager.GetIconById(currentIconId, IconManager.IconTypes.Item);

        CurrentIcon.overrideSprite = icon;

        if (openedBoxes.ContainsKey(selectedIndex))
        {
            // this container has been opened, show the items...
            if (PF_GameData.IsContainer(selectedItem.ItemId))
            {
                CurrentIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(currentIconId + "_Open", IconManager.IconTypes.Item);
            }
            EnableContainerMode(true);
            return;
        }

        // test bundles here....
        // if bundle, we need to show the contents, but not remove it from the list, as it will be unpacked and added automatically
        if (selectedItem.Bundle != null && (selectedItem.Bundle.BundledItems != null || selectedItem.Bundle.BundledResultTables != null || selectedItem.Bundle.BundledVirtualCurrencies != null))
        {
            var bundleItems = new List <ContainerResultItem>();

            if (selectedItem.Bundle.BundledItems != null && selectedItem.Bundle.BundledItems.Count > 0)
            {
                foreach (var award in selectedItem.Bundle.BundledItems)
                {
                    var catalogItem = PF_GameData.GetCatalogItemById(award);
                    var awardIcon   = PF_GameData.GetIconByItemById(award);
                    bundleItems.Add(new ContainerResultItem
                    {
                        displayIcon = GameController.Instance.iconManager.GetIconById(awardIcon, IconManager.IconTypes.Item),
                        displayName = catalogItem.DisplayName
                    });
                }
            }

            if (selectedItem.Bundle.BundledResultTables != null && selectedItem.Bundle.BundledResultTables.Count > 0)
            {
                foreach (var award in selectedItem.Bundle.BundledResultTables)
                {
                    bundleItems.Add(new ContainerResultItem
                    {
                        displayIcon = GameController.Instance.iconManager.GetIconById("DropTable", IconManager.IconTypes.Misc),
                        displayName = string.Format("Drop Table: {0}", award)
                    });
                }
            }

            if (selectedItem.Bundle.BundledVirtualCurrencies != null && selectedItem.Bundle.BundledVirtualCurrencies.Count > 0)
            {
                foreach (var award in selectedItem.Bundle.BundledVirtualCurrencies)
                {
                    bundleItems.Add(new ContainerResultItem
                    {
                        displayIcon = GameController.Instance.iconManager.GetIconById(award.Key, IconManager.IconTypes.Item),
                        displayName = string.Format("{1} Award: {0:n0}", award.Value, award.Key)
                    });
                }
            }

            if (bundleItems.Count > 0)
            {
                openedBoxes.Add(selectedIndex, bundleItems);
                EnableContainerMode(true);
                // dont fall through the rest of the logic.
                return;
            }
        }

        if (PF_GameData.IsContainer(selectedItem.ItemId))
        {
            EnableContainerMode();
        }
        else
        {
            DisableContainerMode();
        }
    }